**From New Scientist #1103, 18th May 1978** [link]

There has been a great craze for football recently on the Island of Imperfection and I have been fortunate enough to get some details of games played there.

There are three tribes on the Island — the Pukkas, who always tell the truth; the Wotta-Woppas, who never tell the truth; and the Shilli-Shallas, who make statements which are alternately true and false, or false and true.

Three teams, one from each tribe, have been having a competition, in which eventually they will play each other [once] — or perhaps they have already done this. The secretaries of the three teams have been asked to give details of the number of matches played, won, lost and drawn and they do this in accordance with the rules of their tribe — so that, for example, all the figures given by the secretary of the Wotta-Woppa team will be wrong.

The figures given are as follows (calling the teams *A*, *B* and *C* in no particular order):

(In no instance did a team win by a majority of more than three goals).

Find the tribe to which each of the three teams belong, and the score in each match.

[puzzle52]

### Like this:

Like Loading...

The following Python code runs in 102ms.

Run:[ @repl.it ]Solution:A are Pukkas, B are Wotta-Woppas, C are Shilli-Shallas. The scores in the matches are: A vs B = 2-2, A vs C = 1-0, B vs C = 3-0.The

iproduct()function takes a (bounded) sequence of (potentially unbounded) iterators and generates tuples corresponding to the Cartesian product of the tuples, every tuple would eventually appear, but if some of the iterables are unbounded the function will never finish (and will eventually run out of memory). The standarditertools.product()function does not operate on unbounded iterators.The program stops after it finds the first solution, and in fact this is the only possible solution.