### Random Post

### Recent Posts

### Recent Comments

### Archives

### Categories

- article (11)
- enigma (1,183)
- misc (2)
- project euler (2)
- puzzle (46)
- site news (46)
- tantalizer (49)
- teaser (3)

### Site Stats

- 184,820 hits

Advertisements

Programming Enigma Puzzles

20 February 2013

Posted by on **From New Scientist #2520, 8th October 2005**

Nimrod is the most famous of Elgar’s Enigma Variations, so it is appropriate that I can write:

In this, digits have been consistently replaced by letters, different letters representing different digits, with the letter O representing the digit zero.

What is the 6-digit number represented by ENIGMA?

According to my diary, this was the first *Enigma* puzzle I programmed a solution for when it was published. Subsequently I only did the puzzles sporadically until **Enigma 1482**, when I started coding solutions every week. Since putting up my solutions on this site I have been working to provide solutions to previous *Enigma* puzzles that I didn’t solve at the time of publication. Currently there are 342 *Enigma* puzzles (and solutions) on the site.

[enigma1361]

Advertisements

%d bloggers like this:

When it was published I solved this puzzle using a Perl program with 8 nested loops. It ran in 757ms. I recoded it in Python using

`itertools.permutations()`

, and that ran in 617ms. But this program uses the`SubstitutedSum`

solver from theenigma.pylibrary and runs in 50ms.Solution:ENIGMA = 785463.Now the

enigma.pylibrary includes code to invoke theSubstitutedSum()solver directly from the command line this kind of problem can be solved without the need to write a program at all.I thought this was quite fitting as

Enigma 1361was the firstEnigmapuzzle I wrote a program for.A MiniZinc solution shows why the letter O must be zero – otherwise there would be two more solutions

Without the additional condition ELGAR + ENIGMA = NIMROD has three distinct solutions.

Giving the value of any one of the letters leads to a unique solution, with the exception of A=3, which gives two solutions.