# Enigmatic Code

Programming Enigma Puzzles

## Enigma 233: Imagine an Enigma

From New Scientist #1379, 13th October 1983 [link]

In this week’s puzzle the ENIGMA is a whole number of gross, and IMAGINE another whole number of gross, over GO times as many as in the ENIGMA.

As usual each letter stands for a digit, and, different letters represent different digits.

IMAGINE / ENIGMA > GO

Please work out what the letters stand for, and find the value of AGAIN.

Note: 1 gross is 12 dozen, i.e. 144.

Note: I am still waiting for a phone line to be connected at my new house, so I only have sporadic access to the internet at the moment. I’ve no idea when I will get connected.

[enigma233]

### 3 responses to “Enigma 233: Imagine an Enigma”

1. Jim Randell 29 October 2014 at 12:35 pm

This Python program runs in 44ms.

```from enigma import irange, diff, printf

# consider 6-digit multiples of 144
for i in irange(695, 6944):
# calculate ENIGMA
ENIGMA = str(i * 144)
# split into letters
(E, N, I, G, M, A) = ENIGMA
# I cannot be 0 and they should all be different
if I == '0' or len(set(ENIGMA)) != 6: continue
# calculate IMAGINE
IMAGINE = int(I + M + A + G + I + N + E)
# it should be a multiple of 144
(j, r) = divmod(IMAGINE, 144)
if r > 0: continue
# consider possible values for O
for O in diff('0123456789', ENIGMA):
GO = int(G + O)
# IMAGINE / ENIGMA > GO
if j > i * GO:
AGAIN = A + G + A + I + N
printf("AGAIN={AGAIN} [ENIGMA={ENIGMA} IMAGINE={IMAGINE} GO={GO}]")
```

Solution: AGAIN = 64691.

The letters are: A=6; E=2; G=4; I=9; M=5; N=1; O=0 or 3.

2. Naim Uygun 29 October 2014 at 1:24 pm
```#enigma= 219456  again= 6 4 6 9 1
from itertools import permutations

for e,n,i,g,m,a,o in permutations(range(1,10),7):

enigma=100000*e+10000*n+1000*i+100*g+10*m+a
if enigma//144 != enigma/144: continue

imagine=1000000*i+100000*m+10000*a+1000*g+100*i+10*n+e
if imagine//144 != imagine/144: continue

go=10*g+o
if imagine/enigma > go:
print("enigma=",enigma, " again=",a,g,a,i,n)
```
• Jim Randell 31 October 2014 at 4:58 pm

I think you need to consider that one of A, M, N, O could be 0 (zero).

If you modify your program to do that you’ll find both solutions.

This site uses Akismet to reduce spam. Learn how your comment data is processed.