# Enigmatic Code

Programming Enigma Puzzles

## Enigma 259: Half burnt

From New Scientist #1406, 19th April 1984 [link]

“Just for once,” said Uncle Bungle, “I will make up a football puzzle in which all the information is included, instead of one with about half the figures left out.”

He undoubtably meant well — my uncle nearly always does. But as so often his plan went sadly wrong. He was doing a bit of tidying up and the wrong piece of paper — or rather half of it — got thrown on the fire.

(2 points are given for a win and 1 point for a draw).

Calling the five teams A, B, C, D and E in that order find who played whom and the score in each match.

(They are all to play each other once eventually. C had not yet played E).

[enigma259]

### One response to “Enigma 259: Half burnt”

1. Jim Randell 18 February 2015 at 7:59 am

This Python program uses the Football() helper class from the enigma.py library. It runs in 50ms.

```from enigma import Football, printf

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

# the 10 matches are:
#
# AvB AvC AvD AvE BvC BvD BvE CvD CvE DvE
#
# CvE has not been played
#
# both A and D have no points, so AvD cannot have been played

# consider the possible remaining matches
# (they cannot be wins or draws for A or D)
for (AB, AC, AE, BC, BD, BE, CD, DE) in football.games('lx', 'lx', 'lx', 'wdlx', 'wx', 'wdlx', 'wx', 'lx'):

# check the points for B, C, E
B = football.table([AB, BC, BD, BE], [1, 0, 0, 0])
if B.points != 7: continue
C = football.table([AC, BC, CD, CE], [1, 1, 0, 0])
if C.points != 3: continue
E = football.table([AE, BE, CE, DE], [1, 1, 1, 1])
if E.points != 4: continue

# now examine possible scorelines for D
for (sAD, sBD, sCD, sDE) in football.scores([AD, BD, CD, DE], [1, 1, 1, 0], 0, 2):
# remaining scorelines for C
for (sAC, sBC, sCE) in football.scores([AC, BC, CE], [1, 1, 0], 4, 0, [sCD], [0]):
# remaining scorelines for A
for (sAB, sAE) in football.scores([AB, AE], [0, 0], 4, 10, [sAC, sAD], [0, 0]):
# remaining scoreline (for B)
for (sBE,) in football.scores([BE], [0], 9, 5, [sAB, sBC, sBD], [1, 0, 0]):

# check scorelines for E
if football.goals([sAE, sBE, sCE, sDE], [1, 1, 1, 1]) != (7, 7): continue