New Scientist Enigma 512 – Sufficient Evidence
by Eric Emmet
From Issue #1664, 13th May 1989
Four football teams are to play each other once. After some of the matches have been played a document giving some details of the matches played, won, lost and so on looked like this:
\[\begin{array}{|c|c|c|c|c|c|c|c|}
\hline Team & Played & Won & Lost & Drawn & Goals\;For & Goals\;Against & Points \\
\hline A & 2 & 1 & & & 5 & 5 & \\
\hline B & & 0 & & 1 & 3 & & \\
\hline C & 2 & & & & & 0 & \\
\hline D & & & 2 & & 5 & 12 & 1 \\
\hline \end{array}\]
Two points are given for a win and one point to each side in a drawn match.
Find the score in each match.
One Comment
Leave one →
-
Brian Gladman permalink1234567891011121314151617181920212223242526272829303132from football import Footballf = Football('ABCD', outcomes='uldw', scoring={'w':2, 'd':1}, sep='')for d1 in f.games(dict(), 'A'):At = f.table(d1, 'A')if At.p != 2 or At.w != 1:continuefor d2 in f.games(d1, 'B'):Bt = f.table(d2, 'B')if Bt.w != 0 or Bt.d != 1:continuefor d3 in f.games(d2, 'C'):Ct = f.table(d3, 'C')if Ct.p != 2:continuefor d4 in f.games(d3, 'D'):Dt = f.table(d4, 'D')if Dt.pts != 1 or Dt.l != 2:continuefor d5 in f.matches(d4, 'A', 5, 5):for d6 in f.matches(d5, 'D', 5, 12):for d7 in f.matches(d6, 'B', 3, (0, 10)):for d8 in f.matches(d7, 'C', (0, 10), 0):nm, rs, gs = f.results(d8)print(', '.join(f"{n} {s}" for n, s in zip(nm, rs)))