Enigmatic Code

Programming Enigma Puzzles

Enigma 1634: Symphonic buttons

From New Scientist #2800, 19th February 2011 [link]

I was playing with my touch-tone phone to see whether I could play tunes, and I had just discovered that I could make a reasonable approximation to the opening bars of Beethoven’s Fifth Symphony by keying 8883 2221 (using a rhythm similar to the Morse code for “v v”: • • • – • • • –), when I dropped the phone and all the buttons 1 to 9 fell out. I pushed them back, but then saw that no button was in its correct place. I did notice that the top three rows were now perfect squares.

Enigma 1634

What buttons do I now press to play Beethoven’s opening bars?

[enigma1634]

One response to “Enigma 1634: Symphonic buttons

  1. jimrandell 12 December 2011 at 5:41 pm

    The following Python program runs in 34ms.

    from itertools import permutations
    from enigma import is_square
    
    # find 3 digit square numbers
    squares = []
    for n in range(100, 1000):
      if not is_square(n): continue
      s = set(list(str(n)))
      if len(s) < 3: continue
      if '0' in s: continue
      squares.append(str(n))
    
    # find pairs of 3 digit squares
    for (a, b, c) in permutations(squares, 3):
      t = a + b + c
      s = set(list(t))
      if len(s) < 9: continue
      if a[0] == '1' or a[1] == '2' or a[2] == '3': continue
      if b[0] == '4' or b[1] == '5' or b[2] == '6': continue
      if c[0] == '7' or c[1] == '8' or c[2] == '9': continue
      print(a, b, c, sep="\n")
    
      print(tuple(map(lambda x: int(t[x-1]), (8, 8, 8, 3, 2, 2, 2, 1))))
    

    Solution: You should press: 6664 8887.

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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: