# Enigmatic Code

Programming Enigma Puzzles

## Puzzle 74: Football (three teams, old method)

From New Scientist #1125, 19th October 1978 [link]

Three football teams (AB and C) are to play each other once. After some — or perhaps all — the matches had been played, a table giving some details of goals, and so on, looked like this:

Two points are given for a win and one point to each side in a drawn match.

Find the score in each match.

[puzzle74]

### One response to “Puzzle 74: Football (three teams, old method)”

1. Jim Randell 26 April 2017 at 8:31 am

We can solve this puzzle directly using the Football() helper class from the enigma.py library.

This Python program runs in 54ms.

```from enigma import Football

# scoring system
football = Football(points={ 'w': 2, 'd': 1 })

# numbers in the table stand for themselves
d = { '2': 2, '3': 3, '5': 5, '7': 7, '8': 8 }

# labels for the teams
(A, B, C) = (0, 1, 2)

# determine the outcomes in the matches
for (m, _) in football.substituted_table({ 'points': '2??' }, d=d):

# determine the scores (using teams A and C)
for s in football.substituted_table_goals('5?7', '8?3', m, d=d, teams=[A, C]):

# check goals against B
(f, a) = football.goals([s[(A, B)], s[(B, C)]], [1, 0])
if a != 11: continue

# output the matches and scores
football.output_matches(m, s, teams='ABC')
```

Solution: The scores in the matches are: AvB = 4-8, AvC = 1-0; BvC = 2-7.