Enigmatic Code

Programming Enigma Puzzles

Enigma 1664: Summer sextet

From New Scientist #2830, 17th September 2011 [link]

My nephew Ignatius has set me a problem. He has written down the digits 0 to 9 in ascending order, and has struck out zero and three other digits. He assigned the remaining six, in ascending order, to the letters P, A, Y, E, R and S, respectively. He then produced the sum shown, translated from six three-digit numbers, and their total.

To what number does PAYERS correspond?

[enigma1664]

Advertisements

One response to “Enigma 1664: Summer sextet

  1. Jim Randell 4 December 2011 at 12:12 am

    A little observation makes this a very short program.

    The following Python code runs in 30ms

    # NOTE: each column sums P+A+Y+E+R+S, so the sum is 111*(P+A+Y+E+R+S)
    
    from itertools import combinations
    from enigma import irange, concat
    
    # s = (P, A, Y, E, R, S)
    for s in combinations(irange(1, 9), 6):
      if 111 * sum(s) == int(concat(s[2], s[1], s[0], s[5])):
        print(concat(*s))
    

    Solution: PAYERS = 123689.

Leave a Comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: