Enigmatic Code

Programming Enigma Puzzles

Tantalizer 431: Hand signals

From New Scientist #982, 8th January 1976 [link]

Here is a strange fact about the parish council at Loose Chippings. The left-handed members always tell the truth but the right-handed members never do. Or perhaps it is the other way round. At any rate ambidextrous members certainly make just one true statement in every two.

And here is what five members have to say about each other:

Alfred: “Bernie is left-handed. Edward is left-handed.”
Bernie: “Alfred is right-handed. David is right-handed.”
Charles: “Alfred is ambidextrous. I am ambidextrous.”
David: “Charles is left-handed. I am right-handed.”
Edward: “Alfred is left-handed. Bernie is ambidextrous.”

Who is what?


One response to “Tantalizer 431: Hand signals

  1. Jim Randell 17 April 2019 at 8:09 am

    This Python program examines all the possible arrangements. It runs in 106ms.

    Run: [ @repl.it ]

    from itertools import product
    from enigma import tuples, printf
    # T = always tells the truth
    def T(ss):
      return all(ss)
    # F = always tells lies
    def F(ss):
      return not any(ss)
    # X = alternates between true and false
    def X(ss):
      return all(a ^ b for (a, b) in tuples(ss, 2))
    # choose an assignment for Left, Right handers
    for (L, R) in [(T, F), (F, T)]:
      # assign traits to each
      for (A, B, C, D, E) in product((L, R, X), repeat=5):
        # check the statements for each person
        if not all([
          A([B is L, E is L]),
          B([A is R, D is R]),
          C([A is X, C is X]),
          D([C is L, D is R]),
          E([A is L, B is X]),
        ]): continue
        # output solution
        (nL, nR, nA, nB, nC, nD, nE) = (x.__name__ for x in (L, R, A, B, C, D, E))
        printf("L={nL} R={nR}: A={nA} B={nB} C={nC} D={nD} E={nE}")

    Solution: A is left-handed; B is ambidextrous; C is left-handed; D is right-handed; E is right-handed.

    Left-handers always lie, and right-handers always tell the truth.

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: