# 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]

### 5 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

3. geoffrounce 8 March 2018 at 7:17 pm
```% A Solution in MiniZinc
include "globals.mzn";

var 0..9: E;  var 0..9: N;  var 0..9: I;  var 0..9: G;
var 0..9: M;  var 0..9 :A;  var 0..9: H;  var 0..9: T;

% same digits as  ENIGMA
var 0..9: e;  var 0..9: n;  var 0..9: i;  var 0..9: g;  var 0..9: m;  var 0..9: a;

constraint all_different( [E, I, G, H, T, M, A, N]) /\ E > 0 /\ G > 0 /\ H  > 0 /\ T > 0;

var 100000..999999: ENIGMA = 100000*E + 10000*N + 1000*I + 100*G + 10*M + A;
var 100000..999999: enigma = 100000*e + 10000*n + 1000*i + 100*g + 10*m + a;

var 100..999: GGG = 111 * G;
var 100..999: HHH = 111 * H;
var 100..999:TTT = 111 * T;

constraint  ENIGMA == GGG * TTT;

constraint GGG * HHH == enigma /\ e > 0;

var set of int: s1 = {E, N, I, G, M, A};

var set of int: s2 = {e, n, i, g , m, a};

% the product of GGG and HHH has the same digits as ENIGMA
constraint s2 == s1;

solve satisfy;

output ["ENIGMA = " ++  show(ENIGMA) ++ ",  GGG * HHH =   " ++ show(enigma)  ] ++
[ "\nEIGHTMAN = " ++ show (E),show(I),show(G),show(H),show(T), show(M),show(A),show(N)];

% ENIGMA = 258741,  GGG * TTT =   517482
% EIGHTMAN = 28763415
% ----------
% ==========
% Finished in 158msec

```
4. Jim Randell 22 March 2018 at 7:44 am

Here’s a solution using the SubstitutedExpression() solver from the enigma.py library.

This run file executes in 135ms.

```#!/usr/bin/env python -m enigma -r

SubstitutedExpression