Skip to content

Sunday Times Teaser 2613 – Anagrammatical

by Nick MacKinnon

Published: 21 October 2012 (link)

The number 258 is special in the following way. If you write down its six different anagrams (258, 285, 528, etc), then calculate the fifteen differences between any two of those six (27, 270, 243, etc) and then add up those fifteen differences, you get 4644, which is a multiple of the number 258 that you started with!

Which higher three-figure number has the same property?

8 Comments Leave one →
  1. Brian Gladman permalink

    Two for the price of one this week!

  2. geoffrounce permalink

    Here is my version:

  3. Brian Gladman permalink

    Hi Naim,

    Your post was badly formatted and had some errors in it so I have corrected it. Let me know if you are not happy with it now.

    I would be grateful if you would avoid giving the answers in your programs since we should let people run the programs if they want the the answers.

  4. Here’s another one:

    • Of course the use of combinations in lines 3 and 6 would have simplified the code:

  5. geoffrounce permalink

    Hi All
    I put in some timers for all six solutions offered, with the following results:

    Brian 1 – 0.0243 sec
    Brian 2 – 0.0055 sec
    Geoff – 0.0105 sec
    Naim – 0.0137 sec
    Arthur 1 – 0.0044 sec
    Arthur 2 – 0.0047 sec

    Timings do vary slightly on re-runs, all timings on my I7 machine.
    Congrats to Arthur and Brian on achieving a 5 millisec run-time !

  6. Brian Gladman permalink

    It appears that some Python interpretors handle the explicit expansion of lists from iterables better than they handle the iterables directly. For example, using this program based on Arthur’s code with only lines 16 and 24 differeent:

    I find the second version runs 50% slower than the first with the main Python interpretor (Python 3.3 from http://www.python.org). But using pypy (version 1.9) there is very little difference between them.

Leave a Reply

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

Subscribe to this comment feed via RSS