# Enigmatic Code

Programming Enigma Puzzles

## Enigma 24: A was absent

From New Scientist #1166, 2nd August 1979 [link]

Things have got very slack on the Island of Imperfections recently, since the arrival of the Jokers, and it seems to happen quite often now that when someone is really needed they are not to be found. The other day, for example, in one of the tribal tests which are — and I hope always will be — an integral part of life in this wonderful place, A was just not to be found. But I had better explain.

There are four tribes on the island, The Pukkas, who always tell the truth, the Wotta-Woppas, who never tell the truth, the Shilli-Shallas, who make statements which are alternately true and false or false and true, and the Jokers whose rules, when three statements are made, are any rules that are different from any of the other three tribes.

This story deals with four men, ABC and D, one from each tribe. BC and D speak as follows:

B: 1. I am a Joker; 2. C sometimes tells the truth; 3. D is a Pukka.

CA is a Pukka.

DB is a Joker.

But where was A? Although he was not around you should be able to find the tribes to which the four men belong.

[enigma24]

### One response to “Enigma 24: A was absent”

1. Jim Randell 26 December 2012 at 10:14 am

The following Python program runs in 39ms.

```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))

for (A, B, C, D) in permutations((P, W, S, J)):
# B's statements
Bs = [(B == J), (C == S or C == J), (D == P)]
if not B(Bs): continue
# C's statements
Cs = [(A == P)]
if not C(Cs): continue
# D's statements
Ds = [(B == J)]
if not D(Ds): continue

(a, b, c, d) = (f.__name__ for f in (A, B, C, D))
printf("A={a} B={b} C={c} D={d}")
```

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.