Enigmatic Code

Programming Enigma Puzzles

Enigma 1348: Team promotions

From New Scientist #2507, 9th July 2005

All the teams in our area have until now been divided up into a number of identical local leagues, but from next season they will come together to play each other in an area league in which each team will play each of the other teams once. All matches will be completed in less than a year even though each team will play on average less than one match a week.

The number of teams that will be promoted from the area league at the end of the season has not yet been decided. The number of different combinations of teams that could be promoted if four teams are promoted is a multiple of the number of different combinations of teams that could be promoted if three teams are promoted, and the latter number is itself a multiple of the number of different combinations of teams that could be promoted if two teams are promoted.

How many teams will be in the area league?

[enigma1348]

One response to “Enigma 1348: Team promotions”

1. Jim Randell 9 February 2014 at 9:00 am

This Python program runs in 33ms.

```# the teams used to be organised into identical leagues, so the total
# number of teams (n) must be a composite (non-prime) number.
#
# we are considering promoting 4, 3 or 2 teams from the league, so
# there must be 5 or more teams altogether (and 5 is prime, so
# actually 6 or more).
#
# each team plays each of the other n-1 teams in a year (52 weeks),
# but on average plays less than 1 match per week, so n - 1 < 52,
# so n < 53.

from enigma import irange, C, is_prime, printf

# consider possible number of teams
for n in irange(6, 52):
# calculate the numbers of combinations
c4 = C(n, 4)
c3 = C(n, 3)
c2 = C(n, 2)
# check c4 is a multiple of c3 and c3 is a multiple of c2
if not(c4 % c3 == 0 and c3 % c2 == 0): continue
# n must be composite
if is_prime(n): continue
# print solutions
printf("n={n} [c4={c4} c3={c3} c2={c2}]")
```

Solution: There will be 35 teams in the area league.