### 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,353 hits

Programming Enigma Puzzles

8 January 2012

Posted by on **From New Scientist #2767, 3rd July 2010** [link]

I have assigned a whole number to each letter of the alphabet. These numbers are not necessarily different and they include negatives and zero. With these numbers I found that

O + N + E = 1

T + W + O = 2

T + H + R + E + E = 3

and so on all the way up to

T + W + E + N + T + Y + N + I + N + E = 29.

Unfortunately, I now find that I made one slip in my additions. Just one of my 29 equations was wrong.

Which equation is wrong?

What should the sum of the letters equal in that case?

[enigma1602]

Advertisements

%d bloggers like this:

This is a tricky one to solve programatically. With a bit of logic and some tussling with simultaneous equations this is easy to solve on paper. I toyed with the idea of writing code to solve the (simplified) simultaneous equations in this problem, and then I found the marvellous SymPy library, which can do all this and more. It feels a bit like using a sledgehammer to crack a nut, but here it is.

It’s Python2.7 code (SymPy wouldn’t install on my Python3.2 installation), and it runs in 3.7s. If you’re willing to accept the logic that equations (1)-(9),(20)-(29) and (14),(16),(17),(19) must all be correct, you can get the runtime down to less than 1s.

Solution:T + H + I + R + T + E + E + N = 2.I did a full solution in MiniZinc, giving the answer that the 13th equation was incorrect.

I found two sets of letter values which gave the same solution.

I checked all the 29 equations with the first set of letter values and they were all correct, except for the 13 th equation The programme found the 2 sets of letter values (giving the same answer) in 798 msec.

Twelve of the letters have fixed values, but the values of the remaining four letters cannot be determined.

So, we have:

But the remaining letters can take on any value that satisfies the following parameterisation for any integer

:kIn the equations given in the question the coefficients of

always cancel out, so its value cannot be determined.kThis also shows that we cannot extend the problem to T + H + I + R + T + Y as this sum has a value of −9. But by assigning a value of

Z =we could have Z + E + R + O = 0.k+ 4Setting

= −37 sets the value ofkR = 42and allows the equations for 40 – 49 to work, but the other numbers from 30 – 99 all have values that are independent of, and none of them work correctly.k