5
2
Here is a real question somebody asked me. Suppose you have n
teams, one terrain.
- Each team must play each other team exactly once.
- The number of times a team plays two matches in a row should be minimized.
The problem is hard if not optimized. Your program should be able to answer this question for up to 6 teams (at least) in a reasonable time (say less than an hour). For 5 teams I have a working program which works in less than a minute.
Here is an example for 5 teams.
$ organize_for 5
[(3,5),(1,2),(4,5),(1,3),(2,4),(1,5),(2,3),(1,4),(2,5),(3,4)]
And another for 6 teams.
$ organize_for 6
[(2,4),(1,5),(2,3),(1,6),(3,5),(1,4),(2,5),(1,3),(4,6),(1,2),(3,6),(4,5),(2,6),(3,4),(5,6)]
NB for 3 and 4 teams, you'll have at least two occurrences of a team playing two matches in a row.
To win: make the shortest program to answer this problem fast enough to give you a correct answer for 6 teams.
Bonuses:
The median of the median of the waiting time between two matches for all teams should be maximized. Example: from organize_for 5 ; nb match between the next one (sorted, median is the one in the center)
team 1 -> 1, 1, 1 (sorted => 1, 1, 1, median => 1) team 2 -> 2, 1, 1 (sorted => 1, 1, 2, median => 1) team 3 -> 2, 2, 2 (sorted => 2, 2, 2, median => 2) team 4 -> 1, 2, 1 (sorted => 1, 1, 2, median => 1) team 5 -> 1, 2, 2 (sorted => 1, 2, 2, median => 2) medians: (1, 1, 2, 1, 2), sorted => (1, 1, 1, 2, 2) median of the medians = 1.
Generalize for
k
terrains. All match have the same duration.- The most important rules remains a team shouldn't do a match just after another.
- The global time for all matches should be minimized
3
What's the winning criterion?
– Peter Taylor – 2011-09-13T09:11:59.457Sorry about that. The idea is to have the shortest program possible. But it must also be fast enough to give you the answer for 6 teams. – yogsototh – 2011-09-13T14:55:46.573
Where do the bonuses fit in? – Briguy37 – 2011-09-14T13:37:57.420
1Pretty sure you need to tweak this -- as-is, I could post a program that simply outputs
[(2,4),(1,5),(2,3),(1,6),(3,5),(1,4),(2,5),(1,3),(4,6),(1,2),(3,6),(4,5),(2,6),(3,4),(5,6)]
and I would meet this entirely: "To win: make the shortest program to answer this problem fast enough to give you a correct answer for 6 teams." – Matthew Read – 2011-09-14T16:25:26.180