Enigmatic Code

Programming Enigma Puzzles

Enigma 1508: Low numbers

From New Scientist #2670, 23rd August 2008

My old mini-computer screen displayed the entire alphabet in order (followed by other miscellaneous symbols) in a rectangle with the first two rows:

Enigma 1508 - 1

Below the screen were five buttons:

Enigma 1508 - 2

At the start of typing each new word the “A” was highlighted. You then moved to any other letter, one box at a time, using the arrows and pushing the OK button to type the highlighted letter. So typing “THIRTY” could be done in 30 button pushes.

My new computer is of a similar style, but with more letters per row. Now typing LOW can be done in a dozen or fewer button pushes and there are three numbers which, if spelled out, can be done in a dozen or fewer pushes each.

What are those three numerals?



One response to “Enigma 1508: Low numbers

  1. Jim Randell 7 October 2012 at 9:15 pm

    The following Python program runs in 40ms.

    from enigma import irange, printf
    # count the number of key presses required to type <word>
    # where the letters are arranged in rows of <n> letters
    def press(word, n):
      # cursor starts at "A", return value is 0
      (cx, cy, r) = (0, 0, 0)
      for i in word:
        p = LETTERS.index(i)
        (py, px) = divmod(p, n)
        # add horizontal moves, vertical moves, OK
        r += abs(cx - px) + abs(cy - py) + 1
        (cx, cy) = (px, py)
      return r
    # verify the initial condition
    assert press("THIRTY", 4) == 30
    # we're interested in numbers that can be typed in 12 or fewer presses
    # so, anything with more than 6 different letters is out
    NUMBERS = (
      "ZERO", "ONE", "TWO", "THREE", "FOUR", "FIVE", "SIX", "SEVEN", "EIGHT", "NINE",
      "TEN", "ELEVEN", "TWELVE",
    # "LOW" can be done in 12 or fewer presses
    for n in irange(5, 26):
      p = press("LOW", n)
      if p > 12: continue
      printf("LOW, {n} => {p}")
      # find how many of the numbers can be done in 12 or fewer presses
      ns = list(i for i in NUMBERS if press(i, n) < 13)
      if len(ns) != 3: continue
      printf("{n} => {ns}")

    Solution: The numerals are: ONE, TWO, TEN.

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: