Enigmatic Code

Programming Enigma Puzzles

Enigma 164: Putting it squarely

From New Scientist #1309, 10th June 1982 [link]

Four typical solvers of the Enigma live at the four corners of an imaginary square. They all live very happily knee deep in calculators, log tables, string, sticky tape and aspirins, emerging just occasionally to go to work. By trade they are an astronomer, bus driver, cryptographer and dustman. Here are five statements about them, just one of which is false:

(1) Paul lives one mile due NW of the astronomer;
(2) Quentin lives one mile due NE of the bus driver;
(3) Randolph lives one mile due SW of the cryptographer;
(4) Sebastian lives one mile due SE of the dustman;
(5) Randolph lives due S of the dustman.

Find which solver lives in which corner, and what each of their jobs are.

There are now 594 Enigma puzzles on the site, with a complete archive of puzzles from the start of Enigma in February 1979 up to this puzzle, originally set in June 1982 (164 puzzles). And also a complete archive of puzzles from August 2005 to the final Enigma puzzle in December 2013 (428 puzzles).

Numerically this is just over one third of the 1780 Enigma puzzles ever published. Sometimes (at Christmas) there have been multiple puzzles with the same number, so in total I expect there are slightly more than 1780 Enigmas – although there have been a couple of puzzles that have been published more than once as different Enigmas, so that brings the total back down again. Whatever the final tally is I’m choosing to celebrate the fact that I’m one third of the way towards a full archive of all Enigma puzzles now.

I shall keep adding puzzles to the site as time permits. Enjoy!

[enigma164]

Advertisements

One response to “Enigma 164: Putting it squarely

  1. Jim Randell 26 January 2014 at 8:51 am

    This Python program test all possible arrangements and looks for cases where exactly four of the given statements are true. It runs in 44ms.

    # there are two possible square arrangements where some points are
    # aligned N/S and others at 45 degree angles:
    #
    #  0   3         0
    #         and  1   3
    #  1   2         2
    #
    # as distances don't impact on the puzzle we'll keep the co-ordinates
    # integers
    
    from collections import namedtuple, defaultdict
    from itertools import permutations
    from enigma import compare, printf
    
    XY = namedtuple('XY', 'x y')
    
    # direction from p to q
    def direction(p, q):
      return ('S', '', 'N')[compare(p.x, q.x) + 1] + ('W', '', 'E')[compare(p.y, q.y) + 1]
    
    def solve(corners):
      # assign names to the 4 corners
      for (P, Q, R, S) in permutations(corners):
        # assign jobs to the 4 corners
        for (A, B, C, D) in permutations(corners):
    
          # evaluate the statements
          ss = (
    
            # 1. P is NW of A
            direction(A, P) == 'NW',
    
            # 2. Q is NE of B
            direction(B, Q) == 'NE',
    
            # 3. R is SW of C
            direction(C, R) == 'SW',
    
            # 4. S is SE of D
            direction(D, S) == 'SE',
    
            # 5. R is S of D
            direction(D, R) == 'S',
          )
    
          # we want exactly 4 of the statements to be true
          if ss.count(True) != 4: continue
    
          # accumulate names and jobs by direction from the origin
          Z = XY(0, 0)
          r = defaultdict(list)
          for (n, s) in zip((P, Q, R, S), ("Paul", "Quentin", "Randolph", "Sebastian")):
            r[direction(Z, n)].append(s)
          for (j, s) in zip((A, B, C, D), ("Astronomer", "Bus Driver", "Cryptographer", "Dustman")):
            r[direction(Z, j)].append(s)
    
          # output a solution
          for (k, v) in r.items():
            printf("direction={k}: {v}", v=', '.join(v))
          printf('')
    
    # square 1, centre at Z=(0, 0)
    solve([XY(-1, 1), XY(-1, -1), XY(1, -1), XY(1, 1)])
    
    # square 2, centre at Z=(0, 0)
    solve([XY(0, 1), XY(-1, 0), XY(0, -1), XY(1, 0)])
    

    Solution: Paul, the cryptographer, lives at the North corner; Sebastian, the bus driver, lives at the South corner; Randolph, the dustman, lives at the West corner; Quentin, the astronomer, lives at the East corner.

    Enigma 164 - Solution

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: