Skip to content

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?

11 Comments Leave one →
  1. Brian Gladman permalink

    Here is a simple solution

  2. Brian Gladman permalink

    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)

  3. Brian Gladman permalink

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

  4. Andrew permalink

    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 ??

  5. Brian Gladman permalink

    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.

    I have formatted your code and added your correction to it. Thanks for making a contribution.

  6. Andrew permalink

    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?

  7. Brian Gladman permalink

    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).

  8. Andrew permalink

    Dear Brian,
    Thanks for your solution. It certainly gives me a lot of new code words to study!
    About speeds, using my laptop there is always a good second’s delay between running the program and the solution appearing. I think this is mainly the time it takes for the python shell to restart.
    Is this normal?

  9. Brian Gladman permalink

    Hi Andrew,

    Your question is not an easy one to answer since it depends on how your system is set up to run Python programs. When a new Python program is run for the first time, it is compiled into a special ‘byte code’ code version and this can cause a delay. But when it is run again, it does not need to do this conversion again so it should run almost instantly. I run the programs from a Windows command shell and I certainly don’t see anywhere near a second’s delay.

    Python has a timing application called profile that can be used to time a Python program and print out a list of times for parts of the code. The times I report come from using profile, which is worth looking at if you are interested in timings.

Leave a Reply

Note: HTML is allowed. Your email address will not be published.

Subscribe to this comment feed via RSS