# Enigmatic Code

Programming Enigma Puzzles

## Enigma 172: Enigmas galore

From New Scientist #1317, 5th August 1982 [link]

It’s easy to make up Enigmas: here are six letters-for-digits multiplication puzzles in one go! In each case, regarded as a separate problem, each letter stands consistently for a digit and different letters stand for different digits. Unfortunately I shall have to check if it’s possible to find numbers that fit and then discard the impossible puzzles (and if some numbers do fit I shall have to add additional clues to make the answer unique). How many of the following six Enigmas must I discard?

E.NIGMAS = ENIGMA
EN.IGMAS = ENIGMA
ENI.GMAS = ENIGMA
ENIG.MAS = ENIGMA
ENIGM.AS = ENIGMA
ENIGMA.S = ENIGMA

[enigma172]

### 2 responses to “Enigma 172: Enigmas galore”

1. Jim Randell 27 February 2014 at 8:28 am

We can arrive at the solution fairly easily by analysis. But this Python program checks all possible values for the letters. It runs in 3.8s (under PyPy).

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

# record how many solutions there are for each puzzle
r = dict((i, 0) for i in irange(1, 6))

# choose 7 digits for ENIGMAS
for s in permutations(irange(0, 9), 7):
ENIGMA = nconcat(s[:-1])
# consider each puzzle
for i in irange(1, 6):
(a, b) = (nconcat(s[:i]), nconcat(s[i:]))
if a * b == ENIGMA:
r[i] += 1
printf("[{i}] {a} x {b} = {ENIGMA}")

for i in irange(1, 6):
printf("[{i}] {n} solutions", n=r[i])
```

Solution: Five of the equations must be discarded. Only the last one has solutions.

• Jim Randell 27 February 2014 at 8:32 am

Analytically we can see that:

ENIGMA × S = ENIGMA

simplifies to:

S = 1

and any assignment of the remaining digits to E, N, I, G, M, A will give a valid equation. So there are 9!/(9-6)! = 60480 possibilities (before additional constraints, such as disallowing leading zeros, are added).

Similarly the remaining equations can be rewritten as:

AS = 10 + A / ENIGM
MAS = 100 + MA / ENIG
GMAS = 1000 + GMA / ENI
IGMAS = 10000 + IGMA / EN
NIGMAS = 100000 + NIGMA / E

The first and second equations are obviously not going to have solutions.

For the third equation GMA/ENI would be a 1 or 2 digit number, making GMAS = 10xy, but then GMA = 10x and there is no possible assignment of ENI that would make this work.

A similar argument eliminates the fourth and fifth equations from having solutions.

Hence only the last equation given in the puzzle has solutions, and they are all trivial.