# Enigmatic Code

Programming Enigma Puzzles

## Enigma 213: Enigma’s square

From New Scientist #1359, 26th May 1983 [link]

SLA × SLA = ENIGMA
YSSE × YSSE = ENIGMAS

Usual letters-for-digits rules. The same letter is the same digit, different letters are different digits, throughout.

What (in letters) is the result of multiplying YE by EIYIELIGMI?

[Note: I am in the process of moving house, so my time and internet connectivity will be constrained over the next couple of weeks. I’ll keep posting puzzles when I can. Normal service will be resumed when the internet comes to Wales.]

[enigma213]

### 5 responses to “Enigma 213: Enigma’s square”

1. Jim Randell 10 August 2014 at 7:29 am

This Python program uses some useful routines from the enigma.py library. It runs in 43ms.

```from itertools import permutations
from enigma import irange, nconcat, split, is_square, printf

# choose digits for Y, S, E
for (Y, S, E) in permutations(irange(0, 9), 3):
if Y == 0: continue
YSSE = nconcat(Y, S, S, E)
# check ENIGMAS is 7-digit, and matches E and S
ENIGMAS = YSSE ** 2
if ENIGMAS < 1000000 or ENIGMAS > 9999999: continue
(E1, N, I, G, M, A, S1) = split(ENIGMAS, int)
if E1 != E or S1 != S: continue
# SLA ^ 2 = ENIGMA
SLA = is_square(ENIGMAS // 10)
if SLA is None: continue
# check S and A match
(S1, L, A1) = split(SLA, int)
if S1 != S or A1 != A: continue
# map digits to letters
d = dict((x, y) for (x, y) in zip((Y, S, E, N, I, G, M, A, L), 'YSENIGMAL'))
# check all the letters are distinct
if len(d) != 9: continue
# calculate YE * EIYIELIGMI as digits and letters
n = nconcat(Y, E) * nconcat(E, I, Y, I, E, L, I, G, M, I)
r = ''.join(d.get(x, '?') for x in split(n, int))
# print the result
printf("{r}={n} [YSSE={YSSE} ENIGMAS={ENIGMAS} SLA={SLA}]")
```

Solution: The result is MEANINGLESS.

• geoffrounce 11 August 2014 at 9:31 am

Another solution:

```from itertools import permutations

for p in permutations ('0123456789', 9):
s,l,a,e,n,i,g,m,y = p
# check no leading digits are zero in two equations
if all( x != '0' for x in (s,e,y)):
sla = int(s + l + a)
enigma = int(e + n + i + g + m + a)
if sla * sla == enigma:
enigmas = int(e + n + i + g + m + a + s)
ysse = int(y + s + s + e)
if ysse * ysse == enigmas:
ye = int(y + e)
eiyieligmi = int(e + i + y + i + e + l + i + g + m + i)
result = ye * eiyieligmi
str_result = str (result)
# get result of multiplication in words
ndict = dict(zip(p, 'SLAENIGMY'))
word = ''.join(ndict[x] for x in str_result)
print('Multiplying YE by EIYIELIGMI gives ',word)
print('Or', result, ' as a number')
```
2. Tessa Fullwood 10 August 2014 at 1:01 pm

I see you are moving. Good wishes with that. The internet has reached Wales in Alaska! By now!

• Jim Olson 10 August 2014 at 9:23 pm

My puzzle addiction is going to tested.

3. Jim Randell 11 November 2017 at 10:05 am

Here’s a solution using the [[ `SubstitutedExpression()` ]] solver from the enigma.py library to solve the alphametic problem. We then use the solution to substitute digits for letters in the answer.

This Python program runs in 66ms.

Run: [ @repl.it ]

```from enigma import SubstitutedExpression, nsplit, join, printf

# make the alphametic puzzle
p = SubstitutedExpression(
[ "SLA ** 2 = ENIGMA", "YSSE ** 2 = ENIGMAS" ],