|
Melbourne Meeting December 2006 - Problem Specification
Automatic Generation of a Games Fixture
The aim of the excercise is to automatically generate the fixture (which teams play which other team in each round) for any number of teams between 3 and 100. Each team must play each other team only once, Each team will play only one match in any round, byes are only permitted if there are an odd number of teams and then only one bye per team is permitted.
While there are published fixtures for N teams the aim here is to derive the fixture on the fly not by entering the data tables from a published source.
The output is intended for use as a reference for building actual fixtures so the presentation is not important. One form could be an array of teams x teams showing the round number in which they play each other. Eg:
|
REDDOGS |
BIGCATS |
SEAGULLS |
SHARKS |
Bye |
| BOMBERS |
1 |
2 |
3 |
4 |
5 |
| RED DOGS |
. |
3 |
4 |
5 |
2 |
| BIG CATS |
. |
. |
5 |
1 |
4 |
| SEAGULLS |
. |
. |
. |
2 |
1 |
| SHARKS |
. |
. |
. |
. |
3 |
John McDonald’s Solution
John showed
us that if you place an odd number of teams in two rows and then rotate them switching
the odd man out from top to bottom you get a relatively simple algorithm that
achieves the required result.
|
Team play Team
|
|
Team play Team
|
|
|
|
Team 1
|
|
Team 1
|
Team 7
|
|
Team 2
|
Team 7
|
|
Team 2
|
Team 6
|
|
Team 3
|
Team 6
|
|
Team 3
|
Team 5
|
|
Team 4
|
Team 5
|
|
Team 4
|
|
|
With odd
numbered teams the odd man out has the bye. If the competition has even teams (in
this case a Team 8) then the last team plays the odd man out.
John then showed us how he derived the team pairs. Basically:
If the number of teams in the diagram is T (this will equal the number of teams if the number of teams is odd, otherwise it will be one less than the number of teams)
and the round number R is between 1 and T,
and team numbers are between 1 and either T or T + 1,
then the opponent of any team from 1 to T may be determined as follows:
If the team number is less than R, subtract if from R, otherwise subtract it from R + T. This will give the team number of the opponent, unless the result is the original team number itself, in which case the team either has a bye, or plays the team not included in the diagram.
|