# Sunday Times Teaser 2620 – Stating the Obvious

### by Peter G. Chamberlain

#### Published: 9 December 2012 (link)

I have replaced the letters of the alphabet by the numbers 0 to 25 in some order, using different numbers for different letters. So, for example, a three-letter word could represent a number of three, four, five or six digits. With my particular values ONE + ONE = TWO, and ONE is a perfect square.

What number does TWO represent?

Here is a simple solution

Hi Naim,

I don’t think your version works because the puzzle involves decimal digits, not base 26 digits. So if, say, o, n and e are 14, 11 and 21, one is then 141121, not 14 * 26^2 + 11 * 26 + 21.

• Dear Brian, greetings
In case base 10, that program gives many results such as
1225 2450 10 21 15 24 4 10
256 512 2 5 6 4 11 2
441 882 2 23 11 7 18 2
1024 2048 8 22 4 19 14 8
361 722 2 15 11 5 22 2
(in the order : one,two,o,n,e,t,w,o)

Hi Naim, Here is another version that gives the same result as my version above.

An excellent solution, but I wonder if it is the most efficient, in that having narrowed ONE down to one value, you then generate 26*26 possible values for TWO, while in fact it can only have one value (ONE*2). This code reduces the puzzle to seven possible answers from which it is easy to pick the right one:

Whilst this code reduces it to one correct answer:

Much more code, but less computer time ??

Hi Andrew,

Yes, my solution is not particularly fast but since it takes less than 80 milliseconds on my machine, I didn’t see any need to spend time speeding it up.

Hi Brian,

Thanks for formatting my code.
About speed issue; sure, just swapping ideas.
For another time, how would I upload some python code directly to your web-site?

The way to put Python code in comments is explained in the ‘About’ menu item above. In view of the limited width of comments, it helps if you use indents of 2 rather than 4. Here is an alternative solution that is a compromise between speed and code length:

On my machine, this achieves 32ms compared with 31ms for your code (my original code takes about 80ms).