### Random Post

### Recent Posts

### Recent Comments

### Archives

### Categories

- article (11)
- enigma (1,393)
- misc (4)
- project euler (2)
- puzzle (90)
- puzzle# (61)
- site news (62)
- tantalizer (105)
- teaser (7)
- today (1)

### Site Stats

- 244,211 hits

Programming Enigma Puzzles

21 June 2019

Posted by on **From New Scientist #2160, 14th November 1998** [link]

At tennis a set is won by the first player to win 6 games, except that if it goes to 5 games all it is won either 7 games to 5 or 7 games to 6. (As far as this puzzle is concerned, this applies even to the final set).

The match between AndrĂ© and Boris went to a deciding fifth set. At the end of each set that AndrĂ© won, the total number of games played up to that point was always a prime number. At the end of each set that Boris won, the total number of games played up to that point was always a perfect square. No two sets contained the same number of games. If I told you the total number of games played at the end of one particular set you could deduce with certainty who won each individual set and what the score was in each set.

In giving the score of a tennis match, it is the convention to give the score in each set in order, always giving the match-winner’s score first, so that if the score is given as (say) 7-6, 5-7, 6-4, 3-6, 6-2, it shows that the two sets the match-winner lost were the second and fourth, won by the opponent by 7 games to 5 and 6 games to 3, respectively.

Using this convention, tell me who won my match and give me its score.

[enigma1005]

%d bloggers like this:

This Python 3 program generates all possible matches that satisfy the conditions, and then looks at the total number of games in each match after each set is complete to find the set number which causes a match to be uniquely identified. It runs in 134ms.

Run:[ @repl.it ]Solution:A won the match 3-6, 6-2, 6-0, 6-7, 6-1.A won 27 of the games, B won 16.

There are 7 possible matches that satisfy the conditions. Here are the scores (each set in the form A-B), along with the total number of games played after the 3rd set is complete

So the penultimate one is uniquely identified by the total number of games played after the 3rd set is complete.