# Enigmatic Code

Programming Enigma Puzzles

## Enigma 180: Still an enigma

From New Scientist #1325, 30th September 1982 [link]

Our local football league consists of four teams each of which plays each of the other three once in a season. At the end of one season I looked at their results and started to base a letters-for-digits puzzle on them. As always in my problems of this type, I was going to give part of the final league table with teams in points order (and alphabetically in the event of a tie) and with different letters representing different digits. Based on the 2-points-for-a-win/1-for-a-draw system, part of my puzzle was going to be:

Then I read that the point system was to be changed to 3 points for a win and 1 for a draw, so I temporarily discarded the puzzle. But on reflection I see that for the same season of matches the same table above can still be used for one of my standard football problems, but now in the new point system. Of course the values of the letters might have to be different, but because it is for the same set of matches you should be able to complete (with for the same set of numbers) the following table.

[enigma180]

### One response to “Enigma 180: Still an enigma”

1. Jim Randell 31 March 2014 at 9:19 am

This Python program uses the [[ `Football()` ]] class from enigma.py to consider the tables for all possible match outcomes under both scoring systems. It runs in 50ms.

```from enigma import Football, printf

# 2 points for a win and 3 points for a win scoring
football = Football(games='wdl', points={ 'w': 2, 'd': 1 })
football3 = Football(games='wdl', points={ 'w': 3, 'd': 1 })

# generate the tables and check the conditions
def check(football, AB, AC, AD, BC, BD, CD):
B = football.table([AB, BC, BD], [1, 0, 0])
r = B.w
q = B.points - r
if q < 0 or q == r: return
C = football.table([AC, BC, CD], [1, 1, 0])
if C.points != q or C.points > B.points: return
A = football.table([AB, AC, AD], [0, 0, 0])
p = A.d
if p in (q, r) or B.points > A.points: return
D = football.table([AD, BD, CD], [1, 1, 1])
if D.l != p or D.points > C.points: return
return ((p, q, r), (A, B, C, D))

# consider possible match outcomes
for s in football.games(repeat=6):
# and make the tables and check the conditions
t1 = check(football, *s)
if t1 is None: continue

# but the same match outcomes would work under 3 points for a win scoring
t2 = check(football3, *s)
if t2 is None: continue

(AB, AC, AD, BC, BD, CD) = s
printf("AB={AB} AC={AC} AD={AD} BC={BC} BD={BD} CD={CD}")
printf("2 points for a win")
((p, q, r), (A, B, C, D)) = t1
printf("A: w={A.w} d={A.d} l={A.l} pts={A.points}")
printf("B: w={B.w} d={B.d} l={B.l} pts={B.points}")
printf("C: w={C.w} d={C.d} l={C.l} pts={C.points}")
printf("D: w={D.w} d={D.d} l={D.l} pts={D.points}")
printf("p={p} q={q} r={r}")
printf("3 points for a win")
((p, q, r), (A, B, C, D)) = t2
printf("A: w={A.w} d={A.d} l={A.l} pts={A.points}")
printf("B: w={B.w} d={B.d} l={B.l} pts={B.points}")
printf("C: w={C.w} d={C.d} l={C.l} pts={C.points}")
printf("D: w={D.w} d={D.d} l={D.l} pts={D.points}")
printf("p={p} q={q} r={r}")
printf()
```

Solution: The completed table is shown below:

There are two different ways the solution can be achieved:

A vs. B match drawn; A vs. C win for C; A vs. D match drawn; B vs. C match drawn; B vs. D win for B; C vs. D win for C.

A vs. B match drawn; A vs. C match drawn; A vs. D win for A; B vs. C win for B; B vs. D match drawn; C vs. D win for C.

This site uses Akismet to reduce spam. Learn how your comment data is processed.