# Enigmatic Code

Programming Enigma Puzzles

## Puzzle 6: On the silly side of Silly Street

From New Scientist #1057, 23rd June 1977 [link]

On the Island of Imperfection there are three tribes, the Pukkas who always tell the truth, the Wotta-Woppas who never tell the truth, and the Shill-Shallas who make statements which are alternately true and false (or false and true).

The four inhabitants of the Island with whom this story deals live in separate houses all on one side of Silly Street where the numbers of the houses are all odd, from 1 to 41 inclusive.

They speak as follows:

A.1: D’s number is one third of C’s;
A.2: D is a Wotta-Woppa.

B.1: The numbers of all our four houses are multiples of 5;
B.2: C’s number is less than A’s.

C.1: A belongs to the same tribe as I do;
C.2: A Pukka lives in No 35.

D.1: C’s number is greater than B’s;
D.2: B belongs to a more truthful tribe than I do.

You are told that there is at least one representative from each tribe, but only one Shilli-Shalla.

Find their tribes and the numbers of their houses.

[puzzle6]

### One response to “Puzzle 6: On the silly side of Silly Street”

1. Jim Randell 8 January 2020 at 12:07 pm

I wrote a Python program to examine all possibilities. But because there are a lot of ways to allocate the numbers (P(21, 4) = 143,640) it is quote slow – it runs in 3.19s.

Run: [ @repl.it ]

```from enigma import tuples, subsets, irange, 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):
return all(a ^ b for (a, b) in tuples(ss, 2))

# truthfulness scores
truth = { W: 0, S: 1, P: 2 }

# assign tribes to the candidates
for ts in subsets((P, W, S), size=4, select="M"):
# there is only one S and at least one of the other tribes
if not(ts.count(S) == 1 and ts.count(P) > 0 and ts.count(W) > 0): continue
(tA, tB, tC, tD) = ts

# assign house numbers to the candidates
for ns in subsets(irange(1, 41, step=2), size=4, select="P"):

# check the statements
(nA, nB, nC, nD) = ns

# A: D's number is a third of C's; D is W
if not tA([nD * 3 == nC, tD is W]): continue

# B: All the numbers are multiples of 5; C's number is less than A's
if not tB([all(n % 5 == 0 for n in ns), nC < nA]): continue

# C: A and C's tribes are the same; In number 35 lives P
if not tC([tA == tC, any(n == 35 and t == P for (n, t) in zip(ns, ts))]): continue

# D: C's number is greater than B's; B is more truthful than D
if not tD([nC > nB, truth[tB] > truth[tD]]): continue

f = lambda x: x.__name__
printf("A={tA}:{nA} B={tB}:{nB} C={tC}:{nC} D={tD}:{nD}", tA=f(tA), tB=f(tB), tC=f(tC), tD=f(tD))
```

Solution: A is a Pukka, who lives at number 35; B is a Wotta-Woppa, who lives at number 41; C is a Shilla-Shalla who lives at number 39; D is a Wotta-Woppa who lives at number 13.

Analytically:

There must be at least one Pukka. So we consider the possibilities:

Suppose D is a Pukka. Then D.2 has to be true, but B cannot be more truthful than a Pukka. So D cannot be a Pukka.

Suppose B is a Pukka. If D is a Wotta-Woppa then D.2 is true, but this is not possible. So D must be the only Shilla-Shalla, and A.2 is false. So A must be a Wotta-Woppa. And C must be a Pukka (which is impossible as C.1 would be false), or a Wotta-Woppa (which is also impossible as C.1 would be true). So B cannot be a Pukka either.

Suppose C is a Pukka. Then C.1 is true, and so A is a Pukka. So A.2 is true and D is a Wotta-Woppa. So D.2 is false, and B is not more truthful than a Wotta-Woppa, so B must also be a Wotta-Woppa. But then we don’t have a Shilli-Shalla amongst them, which is required. So C cannot be a Pukka either.

Hence A must be (the only) Pukka. This means A.2 is true and D is a Wotta-Woppa. So D.2 must be false, and B must also be a Wotta-Woppa. So C is the Shilla-Shalla, and as C.1 is false, C.2 must be true.

Which gives us the following constraints on the numbers:

C.2: A = 35
B.2: C > A (so C is: 37, 39, 41)
D.1: B > C (so B is: 39, 41)
A.1: C = 3×D

The only possible solution is:

A = 35; B = 41; C = 39; D = 13

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