Sports’ Tournament Perl Quiz-of-the-Week (QOTW):
You are given N sport teams (where N is even) who wish to compete against each
other. Each team should have a match against any other team once and only
once. Moreover, the tournament should take place in N-1 days, where in every
day, each team plays once against some other team. (for a total of N*(N-1)/2
matches, which is the number of possible matches).
Your mission is to write a Perl program that will allocate such a schedule.
The function in question would be called allocate_schedule() and will receive
a single scalar parameter, which is the number of the teams. It will return a
reference to an array of day allocations. Each day allocation will be a
reference to an array that for each index will specify the index of the team
that the team with the index in that array will compete against that day.
So for example:
You can try solving the problem for an N that is a whole power of 2, as this
problem is easier.