### Random Post

### Recent Posts

### Recent Comments

### Archives

### Categories

- article (11)
- enigma (1,158)
- misc (2)
- project euler (2)
- puzzle (40)
- site news (44)
- tantalizer (42)
- teaser (3)

### Site Stats

- 177,959 hits

Advertisements

Programming Enigma Puzzles

13 August 2012

Posted by on **From New Scientist #2684, 29th November 2008** [link]

In the group stage of the European Champions League each of the four teams plays each of the others in both home and away matches, gaining 3 points for a win and 1 point for a draw. Each team has already played five matches. In one group Real is currently in first position, Sporting second, Twente third and United fourth, and these positions will remain unchanged after the final week’s matches, since each of the last three teams will still have fewer points than the team above even if it wins its final match.

If I told you who beat whom in one of the matches already played you could deduce with certainty all the other matches that have been played and their results.

Who beat whom in that match, and how many points does each of these two teams currently have?

[enigma1522]

Advertisements

%d bloggers like this:

Here’s a Python program that runs in 63ms. Algorithmically it’s based on my original Perl program.

Solution:Twente beat Sporting. Sporting has 9 points. Twente has 5 points.Here’s my original Perl program. It runs in 324ms, although moving the rejection tests as early as possible (as I did in the Python code) brings this down to 43ms.