# Enigmatic Code

Programming Enigma Puzzles

## Enigma 1648: Enigmarred

From New Scientist #2814, 28th May 2011 [link]

Below I have listed seven numbers, but I have coded them by consistently replacing digits with letters, with different letters used for different digits:

```CINEMA
ECZEMA
EMMA
ENEMA
ENIGMA
MAMMA
STIGMA```

All but one of the seven numbers is divisible by 9.

Which word represents the number which is not divisible by 9?

[enigma1648]

### One response to “Enigma 1648: Enigmarred”

1. Jim Randell 6 December 2011 at 6:30 pm

The following Python code runs in 49ms.

```from itertools import permutations
from enigma import printf

# how many things in the list are not multiples of nine
def n9(*s):
return len(filter(lambda n: n % 9 > 0, s))

d = set(range(10))
for (A, E, M) in permutations(d, 3):
if 0 in (E, M): continue
EMMA = E * 1000 + M * 110 + A
MAMMA = M * 10110 + A * 1001
if n9(EMMA, MAMMA) > 1: continue

d1 = d.difference([A, E, M])
EMA = 100 * E + 10 * M + A
for N in d1:
NEMA = N * 1000 + EMA
ENEMA = E * 10000 + NEMA
if n9(EMMA, MAMMA, ENEMA) > 1: continue

d2 = d1.difference([N])
for (C, I) in permutations(d2, 2):
if C == 0: continue
CINEMA = C * 100000 + I * 10000 + NEMA
if n9(EMMA, MAMMA, ENEMA, CINEMA) > 1: continue

d3 = d2.difference([C, I])
for Z in d3:
ECZEMA = E * 100000 + C * 10000 + Z * 1000 + EMA
if n9(EMMA, MAMMA, ENEMA, CINEMA, ECZEMA) > 1: continue

d4 = d3.difference([Z])
for G in d4:
IGMA = I * 1000 + G * 100 + M * 10 + A
ENIGMA = E * 100000 + N * 10000 + IGMA
if n9(EMMA, MAMMA, ENEMA, CINEMA, ECZEMA, ENIGMA) > 1: continue

d5 = d4.difference([G])
for (S, T) in permutations(d5, 2):
if S == 0: continue
STIGMA = S * 100000 + T * 10000 + IGMA
if n9(EMMA, MAMMA, ENEMA, CINEMA, ECZEMA, ENIGMA, STIGMA) != 1: continue

s = (EMMA, MAMMA, ENEMA, CINEMA, ECZEMA, ENIGMA, STIGMA)
i = filter(lambda i: s[i] % 9 > 0, range(len(s)))
n = ('EMMA', 'MAMMA', 'ENEMA', 'CINEMA', 'ECZEMA', 'ENIGMA', 'STIGMA')[i[0]]
printf("{n} {s}")
```

Solution: ENEMA is not divisible by 9.