**From New Scientist #1544, 22nd January 1987** [link]

Professor Kugelbaum was unwinding at the Maths Club with a cigar after lunch when a wild-looking man burst in and introduced himself thus:

“My name is TED MARGIN. Juggling with the letters of my name one obtains both GREAT MIND and GRAND TIME. But I digress. Each letter of my name stands for one digit exactly from 1 to 9 inclusive and vice versa. And, do you know,

(A × R × M) / (A + R + M) = 2,

MAD is greater than ART (though RAT is greater than either), and TED = MAR + GIN.

If, in addition, I were to tell you the digit which corresponds to M then you could deduce the one-to-one correspondence between the letters of my name and the digits 1 to 9″.

At this point a helpful butler removed the man, but Kugelbaum was amused to find that the information was quite consistent.

Write the digits 1 to 9 in the alphabetical order of the letters to which they correspond.

[enigma394]

### Like this:

Like Loading...

*Related*

We can solve this puzzle using a couple of routines from the

enigma.pylibrary. First theSubstitutedExpression()solver is used to solve the alphametic expressions, thenfilter_unique()to find solutions that give a unique answer by the value ofM.This Python 2 program runs in 48ms.

Solution:ADEGIMNRT = 139274856.There are 4 further solutions where

M = 3:The program can be adapted to run under Python 3 by using the

unpack()function (from theenigma.pylibrary) when constructing the functions to be passed tofilter_unique(). Line 13 becomes:I found a MiniZinc solution by setting the configuration to multiple outputs and examining the outputs to find a unique answer with M = 4, giving the solution. Four other values with M = 3 were also found.

A Python 3 permutation solution found the answer in 16 msec, with a total run-time of 95 msec.

A Visual Basic (Visual Studio 2017) solution took a lot more coding to loop all the variables and test for different variable values. Output was to a console screen, which seemed a bit of a retro look.

In a

permutations()based approach, once we have determined values for A, M, R we don’t need to consider all 720 possible permutations of the remaining six digits for D, E, G, I, N, T, instead we can get away looking at the 120 possible values of just T, E, D (or G, I, N) and check that the values for the remaining three letters, computed from TED = MAR + GIN, consist of the remaining 3 digits.