Enigmatic Code

Programming Enigma Puzzles

Tantalizer 500: Three kings

From New Scientist #1051, 12th May 1977 [link]

Tommy’s homework included the question:

“Pippin, Quorum and Rudolph were all Tantalusian monarchs. In what order did they reign?”

Tommy consulted Uncle George, who remarked:

“Well, Pippin was the first Tantalusian monarch to shoot an elephant. No monarch since Quorum has shot a hippopotamus. And, if Quorum is the most recent of the three, then Pippin was the earliest. That gives you enough to go on, assuming you know who else shot what.”

“But, Uncle, I don’t.”

“No matter — you can work that out too, if you bear in mind that everything I’ve just told you is relevant.”

Who reigned in what order and shot what?

[tantalizer500]

3 responses to “Tantalizer 500: Three kings

  1. Jim Randell 9 March 2016 at 10:20 am

    The Tantalizer answers in the magazine include a solution from the setter. Here it is:

    Answer: 1st. P; 2nd. R: 3rd. Q. P and Q shot elephants; Q and R shot hippos.

    The three key bits of data are:

    (a) If QE then P before Q and if RE then P before R.
    (b) if PH then P before Q and if RH then R before Q.
    (c) if Q3 then P1.

    If (c) is to be used, then (a) and (b) together must imply R1 or P2 or Q3. But (a) and (b) cannot imply either R1 or P2; so we want Q3 from them. For that we shall need RH but not PH (as (a) would then be superfluous and George said that all the data were needed). So we want either QE or RE from (a), but not RE as (c) would then be superfluous, given RH. Hence only QE and RH (but not PH or RE) satisfy George’s conditions.

    Here is my programmed solution:

    This Python program runs in 35ms.

    from itertools import product, combinations
    from enigma import printf
    
    # labels for the monarchs
    (P, Q, R) = (0, 1, 2)
    
    # possibilities for beasts
    beasts = ['', 'E', 'H', 'EH']
    
    # the statements:
    
    # s1: "(Q is most recent) => (P is the earliest)"
    def s1(order, beast):
      return (order[Q] != 3 or order[P] == 1)
    
    # s2: "P was the first monarch to shoot an E"
    def s2(order, beast):
      return ('E' in beast[P]) and not any('E' in beast[x] and order[x] < order[P] for x in (Q, R))
    
    # s3: "no monarch since Q has shot an H"
    def s3(order, beast):
      return ('H' in beast[Q]) and not any('H' in beast[x] and order[Q] < order[x] for x in (P, R))
    
    # compute possible orders, given a beast assignment and a collection of statements
    def orders(beast, ss):
      return list(order for order in permutations([1, 2, 3]) if all(s(order, beast) for s in ss))
    
    # if we knew who shot what we could work out the order
    for beast in product(beasts, repeat=3):
      # look for unique orders
      r = orders(beast, (s1, s2, s3))
      if len(r) != 1: continue
      printf("[beast={beast} -> order={r[0]}]")
    
      # but make sure no two of the statements suffice
      if any(len(orders(beast, ss)) == 1 for ss in combinations((s1, s2, s3), 2)): continue
      printf("SOLUTION (P, Q, R): order={r[0]}, beast={beast}")
    

    Solution: Pippin reigned first (earliest), and hunted elephants. Rudolph reigned in the middle, and hunted hippos. Quorum reigned last (most recently) and hunted both elephants and hippos.

    The puzzle is a little odd, as if we are told that we get a unique solution for the order (which is all we need to know to do the homework) providing we know who hunted what, then we can uniquely determine the ordering of the reigns without the need for further information. There are seven possibilities:

    [1] 1: (P, E); 2: (R, EH); 3: (Q, H)
    [2] 1: (P, E); 2: (R, H); 3: (Q, EH)
    [3] 1: (P, E); 2: (R, EH); 3: (Q, EH)
    [4] 1: (P, EH); 2: (R, H); 3: (Q, H)
    [5] 1: (P, EH); 2: (R, EH); 3: (Q, H)
    [6] 1: (P, EH); 2: (R, H); 3: (Q, EH)
    [7] 1: (P, EH); 2: (R, EH); 3: (Q, EH)

    So the ordering (P, R, Q) is uniquely determined, and this is enough to answer Tommy’s homework, without knowing who hunted what.

    However, we do need to determine who hunted what to answer the puzzle, so we need to know that no two of the three statements is sufficient to produce a unique ordering.

    For example, in case [1] above it turns out that the second and third statements are enough to arrive at a unique solution without the need for the first statement, so this eliminates that case from our enquiries. Similarly all other cases apart from [2] can be eliminated. In case [2] all three statements are required.

  2. Hugh Casement 9 March 2016 at 12:27 pm

    Should the wording perhaps be something like “… what else each of them shot.” ?

    Not sure that I follow the logic, anyway.  Could Pippin not have shot a hippopotamus as well?  Must Quorum necessarily have shot one?  Could they not all three have shot an elephant?  Did Rudolph have to shoot anything at all (or anything larger than a pigeon)?  What about the other unnamed kings (or queens) who may have come somewhere else in the order?

    • Jim Randell 9 March 2016 at 1:27 pm

      I did find the wording a little confusing, but I eventually decided that knowing “who else shot what” (which is the wording used in the original puzzle) was the same as knowing “who shot what”.

      My explanation above is flawed in that there are actually 7 possibilities for “who shot what” that give the unique ordering of (P, R, Q), not 2 as I originally stated. But these are the only combinations that give a unique ordering, and in all of them — except the one that gives the answer to puzzle — just two of the statements suffice. (I’ll fix up my explanation above).

      I think the wording of the third statement does imply that Q shot a hippopotamus, although maybe it would have been better stated as “Q was the last monarch to shoot a hippopotamus”. If you allow the cases where Q doesn’t shoot a hippopotamus you don’t get a unique solution. (Although the (P, R, Q) ordering is still the only possibility).

      I don’t think we need to consider prey animals other than the two mentioned in the context of the puzzle, although I do consider the possibility that a monarch may have hunted neither (or both) of them. Likewise considering other monarchs that are not mentioned doesn’t make any difference to the puzzle.

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: