Enigmatic Code

Programming Enigma Puzzles

Enigma 345: Talking in circles

From New Scientist #1494, 6th February 1986 [link]

Enigma 345

Six girls were sitting equally-spaced around a circular table. Each of them was either honest or consistently told lies.

Anne said: “The person on my left is more honest than me”. None of the other girls would say the same.

Barbara said: “The person on my right is not less honest than me”. None of the other girls was able to say the same.

Christine said that the girl opposite her was of different honesty from her, and Doreen said that the majority of the girls were honest. Eileen said that the people either side of her were honest, and Fiona said that she was between two people of equal honesty.

Fill in the seating plan ticking those who are honest.

[enigma345]

Advertisements

One response to “Enigma 345: Talking in circles

  1. Jim Randell 20 May 2016 at 7:48 am

    This Python program considers the possible seating arrangements. It runs in 49ms.

    from itertools import permutations, product
    from enigma import printf
    
    # comparative positions
    def inc(p, n):
      return (p + n) % 6
    
    left = lambda p: inc(p, 1)
    right = lambda p: inc(p, 5)
    opposite = lambda p: inc(p, 3)
    
    # put A at position 0
    A = 0
    
    # and consider the remaining positions
    for (B, C, D, E, F) in permutations((1, 2, 3, 4, 5)):
      # assign a truth value to each girl
      # "X says Y" corresponds to the expression: t[X] == Y
      for t in product((True, False), repeat=6):
    
        # A: "the person on my left is more honest than me"
        s = lambda x: t[x] == (t[x] == False and t[left(x)] == True)
        if not s(A): continue
        # none of the other girls would say the same
        if any(s(x) for x in (B, C, D, E, F)): continue
    
        # B: "the person on my right is not less honest than me"
        s = lambda x: t[x] == (not(t[x] == True and t[right(x)] == False))
        if not s(B): continue
        # none of the other girls would say the same
        if any(s(x) for x in (A, C, D, E, F)): continue
    
        # C said the girl opposite was of different honesty
        s = lambda x: t[x] == (t[x] != t[opposite(x)])
        if not s(C): continue
    
        # D said the majority of girls were honest
        s = lambda x: t[x] == (t.count(True) > 3)
        if not s(D): continue
    
        # E said the people on either side of her were honest
        s = lambda x: t[x] == (t[left(x)] == t[right(x)] == True)
        if not s(E): continue
    
        # F said she was between two people of equal honesty
        s = lambda x: t[x] == (t[left(x)] == t[right(x)])
        if not s(F): continue
    
        printf("A={A} B={B} C={C} D={D} E={E} F={F} {t}")
    

    Solution: The seating plan is shown below:

    Enigma 345 - Solution

    The final statement (for F) does not narrow down the solutions, nor do the individual statements of A and B.

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: