### Random Post

### Recent Posts

### Recent Comments

### Archives

### Categories

- article (11)
- enigma (1,123)
- misc (2)
- project euler (2)
- puzzle (31)
- site news (43)
- tantalizer (31)
- teaser (3)

### Site Stats

- 168,282 hits

Programming Enigma Puzzles

11 December 2015

Posted by on **From New Scientist #1471, 29th August 1985** [link]

Professor D. O’Phantus does all his calculations in code, with each digit represented by a letter of the alphabet. Each letter always stands for the same digit and each digit is always represented by the same letter. At the end of one of his confusing lectures on “Letter Theory” some examples of calculation remained on the blackboard.

According to the professor:

Sadly, the result of another addition:

had been wiped out, but when it was multiplied by the result of the previous sum it apparently yielded OMTTOUI.

“This is quite hopeless”, said Magnus Swottus. “How can we do lots of lovely homework if we don’t know what the letters stand for? It might as well be Greek.”

But Goody-Goody Major, unwilling to be done out of his homework, was more philosophical. “We’ll just have to crack old Doodah’s code, and then just think of all the problems open to us? We’ll even be able to invent our own!”

Can you help these young enthusiasts by writing out in order the letters corresponding to the digits from 0 to 9?

[enigma323]

Advertisements

%d bloggers like this:

This Python program starts by using the

SubstitutedSum()solver from theenigma.pylibrary to solve the first sum. It runs in 49ms.Solution:The letters corresponding to the digits 0 to 9 are (in order) DEMOCRITUS.The missing result in the second addition sum would be ERRC.

And here’s a version which starts from the result of the multiplication sum. It runs in 36ms.

This solution uses the

SubstitutedExpression()solver from theenigma.pylibrary to solve the Alphametics. We then do a bit of manipulation of the solution to produce the output in the required format. Overall run time is 42ms.Jim, My program in MiniZinc confirms your answer. However, I had to use your sequence of letters as I was unsure about sorting the output in MiniZinc to give the required order.

A Python 3 permutation solution:

A solution in a different programming language- started learning some Fortran 95 recently. Managed to confirm the answer, but printing out only the letters proved too difficult – it does not seem to have the same programming facilities as Python – not sure about later versions of Fortran. I understand Fortran has been going since 1957!

I’ve not really used Fortran (my brother used it at University, but I was using BASIC at the time), but I found I had the GNU Fortran 95 compiler installed on my Raspberry Pi, so I was able to compile and run the program you posted.