# Enigmatic Code

Programming Enigma Puzzles

## Puzzle 21: Cricket (4 teams)

From New Scientist #1072, 6th October 1977 [link]

A, B, C and D have all played each other once at cricket.

Points are awarded as follows:

To the side that wins — 10
To the side that wins on the first innings in a drawn match — 6
To the side that loses on the first innings in a drawn match — 2
To each side for a tie — 5
To the side that loses — 0

A, B, C and D got 10, 11, 17 and 14 points respectively, and you are told that only one match was won outright.

Find the result of each match.

[puzzle21]

### One response to “Puzzle 21: Cricket (4 teams)”

1. Jim Randell 5 June 2019 at 9:40 am

We’ve encountered similar puzzles before. See: Enigma 3, Puzzle 59, Puzzle 32.

This Python program runs in 173ms.

Run: [ @repl.it ]

```from itertools import product
from enigma import printf

# possible scores
scores = ( (10, 0), (6, 2), (5, 5), (2, 6), (0, 10), (0, 0) )

# possible scores in the matches
for s in product(scores, repeat=6):

# only one match was won outright (i.e. (10, 0) or (0, 10))
if sum((10 in x) for x in s) > 1: continue

# calculate the overall totals
(AB, AC, AD, BC, BD, CD) = s
A = AB[0] + AC[0] + AD[0]
B = AB[1] + BC[0] + BD[0]
C = AC[1] + BC[1] + CD[0]
D = AD[1] + BD[1] + CD[1]
if not((A, B, C, D) == (10, 11, 17, 14)): continue