### Random Post

### Recent Posts

### Recent Comments

### Archives

### Categories

- article (11)
- enigma (1,367)
- misc (4)
- project euler (2)
- puzzle (90)
- puzzle# (48)
- site news (58)
- tantalizer (94)
- teaser (7)

### Site Stats

- 233,130 hits

Programming Enigma Puzzles

21 October 2016

Posted by on **From New Scientist #1516, 10th July 1986** [link]

Uncle Bungle has been making up another long division sum with letters substituted for digits, and those who know him well — as I do — will not be surprised to hear that all was not as it should be. Being rather old-fashioned he still uses ink, and being rather careless he has spilt it so that some of the letters were, I’m afraid, quite illegible. What can be read can be seen below, and I am glad to say that what is left is as it should be; that is, each letter stands for a different digit:

Rewrite the complete sum with letters and blanks replaced by digits.

[enigma367]

%d bloggers like this:

We can use the [[

`SubstitutedDivision()`

]] solver from theenigma.pylibrary to solve this problem in one line. Instead of writing a program to do the call we can invoke it directly from the command line. Here’s the command and its output:This runs in 80ms.

Solution:The complete sum is: 20883 / 78 = 267 remainder 57.We can also use the generalised alphametic solver ([[

`SubstitutedExpression()`

]]) from theenigma.pylibrary.We introduce the symbols ABC to stand for the illegible letters (they are inserted as AABC, reading from top to bottom in the diagram). Which gives us the following run file:

Which we can run like this to get the same solution:

This runs in 76ms.

The [[

`SubstitutedExpression()`

]] solver uses a heuristic to choose the number of symbols it has to consider values for. In this case it only needs to look ats,m, andt, the values of the remaining symbols can be derived. The same approach can be used to solve the program manually (or indeed, programatically).