P is for Practical | |
PerlMonks |
Re: Round robin tournament problemby dvergin (Monsignor) |
on Oct 21, 2003 at 23:48 UTC ( [id://301112]=note: print w/replies, xml ) | Need Help?? |
Update: Drat! I suspect Limbic~Region is right about 2**n. This solution fails for groups of 6 and 10. But for groups numbering in powers of two read on.
Unencumbered as I am by any proper background in such things, let me offer this... For each round, for each player in succession who does not yet have an opponent in that round, we pick the first available unmatched person who this player has not played in a previous round. For convenience in screening the possibilities, we keep track of the matchings both ways ( A vs B *and* B vs A). and then weed out the dupes later. You may or may not find this a bit verbose. Season to taste: The rationalle seems right, the code runs, and the results look like they meet the spec. Good luck.
HTH,
------------------------------------------------------------
In Section
Seekers of Perl Wisdom
|
|