New Scientist Puzzle 17 – Goals Rewarded
by Eric Emmet
From Issue #1068, 8th September 1977
A lot of people have been of the opinion for some time that in football competitions some importance should be attached to the number of goals scored as well as to the actual result of the game. It is hoped that this will lead to more goals and therefore to more attractive games.
Three local teams of my acquaintance have been experimenting on these lines. They have had a competition in which they all played each other once, and they have awarded ten points for a win, five points for a draw, no points of course for a loss, and one point for each goal scored.
As a result of this competition one team scored 16 points, the second scored 18 points, and the third scored 10 points. It was interesting to notice that at least one goal was scored by both sides in every match.
What was the score in each match?
-
Brian Gladman permalink1234567891011121314151617181920212223242526272829from football import Footballf = Football('ABC', outcomes='ldw', scoring={'w':10, 'd':5}, sep='')# calculate the total goals for each team from# the known final points and the game outcomesfor d1 in f.games(dict(), 'A'):gfA = 16 - f.table(d1, 'A').ptsfor d2 in f.games(d1, 'B'):gfB = 18 - f.table(d2, 'B').ptsfor d3 in f.games(d2, 'C'):gfC = 10 - f.table(d3, 'C').ptsif all(x >= 2 for x in (gfA, gfB, gfC)):# total 'goals for'gft = gfA + gfB + gfC# find possible match scores with the required goals# for each team (all teams score in all games)fn = lambda x: 0 not in xfor d4 in f.matches(d3, 'A', gfA, (1, gft), fn=fn):t = gft - f.table(d4, 'A').gafor d5 in f.matches(d4, 'B', gfB, (1, t), fn=fn):u = t - f.table(d5, 'B').gafor d6 in f.matches(d5, 'C', gfC, u):res = f.results(d6)[:2]print(', '.join(f"{n}:{r}" for n, r in zip(*res)))