# Enigmatic Code

Programming Enigma Puzzles

## Enigma 1550: Eightman band

From New Scientist #2713, 20th June 2009 [link]

The letters of EIGHTMAN represent different digits. When representing a number, ENIGMA is the product of GGG and TTT. Furthermore, a six-digit number using the letters of ENIGMA in a different order is the product of GGG and HHH.

What is the number EIGHTMAN?

[enigma1550]

### 3 responses to “Enigma 1550: Eightman band”

1. Jim Randell 21 March 2012 at 9:20 pm

Here’s my original Perl solution. This program runs in 11ms.

```my (\$G, \$T, \$H);
my (\$enigma, \$e, \$n, \$i, \$g, \$m, \$a);
my (\$product);
my (\$se, \$sp);

use Enigma qw/distinct/;

for \$G (1..9) {
for \$T (1..9) {
next unless distinct(\$T, \$G);
\$enigma = int("\$G\$G\$G") * int("\$T\$T\$T");
next unless length(\$enigma) == 6;
(\$e, \$n, \$i, \$g, \$m, \$a) = split '', \$enigma;
next unless \$g == \$G;
next unless distinct(\$n, \$e);
next unless distinct(\$i, \$e, \$n);
next unless distinct(\$g, \$e, \$n, \$i);
next unless distinct(\$m, \$e, \$n, \$i, \$g);
next unless distinct(\$a, \$e, \$n, \$i, \$g, \$m);
\$se = join '', sort split '', \$enigma;
for \$H (1..9) {
next unless distinct(\$H, \$T, \$e, \$n, \$i, \$g, \$m, \$a);
\$product = int("\$G\$G\$G") * int("\$H\$H\$H");
next unless length(\$product) == 6;
\$sp = join '', sort split '', \$product;
next unless \$sp == \$se;
print "EIGHTMAN=\$e\$i\$g\$H\$T\$m\$a\$n [G=\$G, T=\$T, H=\$H, ENIGMA=\$enigma GGGxHHH=\$product]\n";
}
}
}
```

Solution: EIGHTMAN = 28763415.

• Jim Randell 21 March 2012 at 9:22 pm

And this is how I would solve it now in Python. This program runs in 35ms.

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

d1 = set(irange(1, 9))
for (G, T) in permutations(d1, 2):
ENIGMA = str(G * T * 12321)
if len(ENIGMA) != 6: continue
(E, N, I, G2, M, A) = split(ENIGMA, int)
if G2 != G: continue
ds = set(list(ENIGMA))
if len(ds) != 6: continue
for H in d1.difference((A, E, G, I, M, N, T)):
p = str(G * H * 12321)
if len(p) != 6: continue
if ds != set(list(p)): continue
printf("EIGHTMAN={E}{I}{G}{H}{T}{M}{A}{N} [G={G} T={T} H={H} ENIGMA={ENIGMA} GGGxHHH={p}]")
```
2. Tessa Fullwood 22 March 2012 at 11:07 am

The answer was published on 1 August. EIGHTMAN is 28763415