# Enigmatic Code

Programming Enigma Puzzles

## Enigma 249: Championship double

From New Scientist #1396, 9th February 1984 [link]

We are drawing up plans for our local club’s annual tennis championship for the next few years. The championship is held for a week in spring and consists of a group of members each playing each of the others just once. We are planning for increased numbers of participants and so we asked the groundsman how many matches the courts could cope with in this and next year’s championships. He gave his figure for this year and said that with the planned club extensions we could cope with twice that figure next year.

The chairman reacted that both those figures were inappropriate as neither equalled a possible “championship total” number of matches, that is to say no matter how many players took part in a championship the number of matches needed could not equal either of the groundsman’s estimates.

So the chairman interpreted these figures by assuming that the number of matches played this year and next would be the lowest “championship totals” above each of the groundsman’s estimates. He then announced his revised estimates for this year’s and next year’s matches and, by coincidence, his figure for next year is twice his figure for this year.

One might be led to believe that the year after next will see three times the number of matches which the chairman predicts for this year; but that is impossible. But it could happen that the number of matches in the championship they year after next is three times the groundsman’s estimate for this year.

How many matches did the groundsman estimate for this year?

[enigma249]

### 3 responses to “Enigma 249: Championship double”

1. Jim Randell 9 January 2015 at 9:02 am

This Python program runs in 33ms.

```# if n players play each other exactly once there are T(n-1) matches

from itertools import count
from enigma import T, is_triangular, irange, first, printf

# the chairman estimates are:
#  this year = c (a triangular number)
#  next year = 2c (a triangular number)
# but 3c is not a triangular number
#
# the groundmans estimates are:
#  this year = g (not a triangular number, but c is the next highest)
#  next year = 2g (not a triangular number, but 2c is the next highest)
# but 3g is a triangular number

def generate():
# look for potential vaules of c
for i in count(1):
# c is a triangular number = T(i)
c = T(i)
# and so is 2c = T(j)
j = is_triangular(2 * c)
if j is None: continue
# but 3c is not a triangular number
if is_triangular(3 * c): continue

# and potential values of g
# T(i - 1) < g < T(i) and T(j - 1) < 2g < T(j)
for g in irange(max(T(i - 1), (T(j - 1) + 1) // 2) + 1, c - 1):
# but 3g is triangular
if not is_triangular(3 * g): continue

printf("[c = {c} = T({i}), 2c = {c2} = T({j}), g = {g}, 3g = {g3} = T({x})]", c2=c * 2, g3=g * 3, x=is_triangular(3 * g))
yield (c, g)

# find the smallest solution
for (c, g) in first(generate(), 1):
printf("groundsman = {g}, chairman = {c}")
```

Solution: The groundsman estimated 100 matches could take place this year.

100 is not a triangular number, and the next highest triangular number is 105, which is the chairman’s estimate for this year (105 = T(14), corresponding to 15 players in the championship).

The groundsman’s estimate for next year is 200, which is also not a triangular number. The next highest triangular number is 210, which is the chairman’s estimate for next year (and twice his estimate for this year), which is T(20) (corresponding to 21 players in the championship).

Thrice the chairman’s estimate for this year is 315, which is not a triangular number. But thrice the groundsman’s estimate for this year is 300, which is a triangular number (= T(24), corresponding to 25 players in the championship).

This is the smallest solution. The next smallest solution is:

The groundsman estimates 121,126 matches could take place this year. (This is not a triangular number). The chairman’s estimate is the next highest triangular number – 121,278 = T(492).

The groundsman’s estimate for next year is 242,252. (Also not a triangular number). The chairman’s estimate for next year is the next highest triangular number – 242,556 = T(696), which is twice his estimate for this year.

Thrice the chairman’s estimate for this year is 363,834, which is not a triangular number. Thrice the groundsman’s estimate for this year is 363,378 = T(852).

And larger solutions can be found, but it is probably not feasible to hold a tennis tournament with hundreds of thousands of matches in a single week.

• Jim Olson 9 January 2015 at 9:04 pm

Aren’t the number of players 15 and 21 respectively? That appears to be the only way you can get to the triangular numbers that are the solution. Fifteen players will play 105 matches and 21 players will play 210 matches if everyone plays everyone else once.
.