Enigmatic Code

Programming Enigma Puzzles

Puzzle 75: C is silent

From New Scientist #1126, 26th October 1978 [link]

The four tribes seem now, for better or worse, to be firmly established on the Island of Imperfection. They are the Pukkas, who always tell the truth; the Wotta-Woppas, who never tell the truth; the Shilla-Shallas, who make statements which are alternately true and false or false and true; and the Jokers, whose rules for truth-telling in making three statements are any rules that are different from those of any of the other three tribes.

In the story which I have to tell about ABC and D there is one member of each tribe. C, I am afraid, does not actually say anything. Can he just be fed-up? I don’t blame him. The other three speak as follows:

A: B is a Pukka;
B: C is a Shilla-Shalla;
D: A is a Pukka;
D: I am a Shilla-Shalla or a Wotta-Woppa;
D: B is a Joker.

Find the tribes to which ABC and D belong.

[puzzle75]

Advertisements

One response to “Puzzle 75: C is silent

  1. Jim Randell 19 April 2017 at 7:01 am

    See Enigma 24 (and also Enigma 47, Enigma 75, Enigma 88).

    This Python program considers all possible assignments of tribes to A, B, C, and D. It runs in 37ms.

    from itertools import permutations
    from enigma import printf
    
    # Pukka - always tells the truth
    def P(ss):
      return all(ss)
    
    # Wotta-Woppa - never tells the truth
    def W(ss):
      return not any(ss)
    
    # Shilli-Shalla - alternates between true and false
    def S(ss):
      (a, b) = (ss[::2], ss[1::2])
      return (all(a) and not(any(b))) or (all(b) and not(any(a)))
    
    # Joker - differ from the others for 3 (or more) statements
    def J(ss):
      return len(ss) < 3 or not(P(ss) or W(ss) or S(ss))
    
    # choose the tribes
    for (A, B, C, D) in permutations((P, W, S, J)):
    
      # A's statements
      As = [(B == P)]
      if not A(As): continue
    
      # B's statements
      Bs = [(C == S)]
      if not B(Bs): continue
    
      # D's statements
      Ds = [(A == P), (D == S or D == W), (B == J)]
      if not D(Ds): continue
    
      # output the solution
      printf("A={A.__name__}, B={B.__name__}, C={C.__name__}, D={D.__name__}")
    

    Solution: A is a Joker; B is a Wotta-Woppa; C is a Pukka; D is a Shilla-Shalla.

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: