### Random Post

### Recent Posts

### Recent Comments

### Archives

### Categories

- article (11)
- enigma (1,314)
- misc (3)
- project euler (2)
- puzzle (78)
- puzzle# (21)
- site news (54)
- tantalizer (80)
- teaser (7)

### Site Stats

- 217,164 hits

Programming Enigma Puzzles

31 October 2018

Posted by on **From New Scientist #993, 25th March 1976** [link]

The usual five football teams entered our local cup and played the usual one game against each of the others. Exactly three of the games were won by the home side. No two teams won the same number of games. There were no drawn games. Each team played two games at home.

The Ayfield Aces won two games. The Barnley Bears were at home to the Aces and to the Cornfield Casuals. The Casuals were at home to the Aces. Ditching Dynamos were at home to the Eggplant Eagles.

What was the result in each of the ten games?

[tantalizer442]

%d bloggers like this:

I wrote a

MiniZincmodel to find the tables for home/away fixtures and win/lose outcomes.This model runs in 139ms.

Solution:E won all four of their games (against A, B, C, D). D won their games against A, B, C (but lost to E). A won their games against B and C (and lost to D and E). C won their game against B (but lost to A, D, E). B lost all four of their games (against A, C, D, E).Here’s a table (1 = win, 0 = lose, yellow = home):

So the three home wins were D at home to B, E at home to B and E at home to C.

I also wrote a Python program to solve this problem. It runs in 113ms.

Run:[ @repl.it ]The interesting bit of code to write was the [[

table()]] function that constructs a 5×5 table from the T(5 – 1) = 10 elements that form the upper right hand part.For each table there are 2^10 = 1024 possibilities before the conditions are applied.

The information about the home games is sufficient that there is only a single “home” table by the time we get to line 39.