|
[SPOILER]match of the week solution: msg#00015lang.perl.qotw.discuss
Not entierly to spec :-) but here's a fairly short RR alocation routine using a circle methaphor. a a a d b -> c d -> b c c b d place all the teams around a circle, keep the one at 12 oclock fixed and rotate the rest. Pair off oposing teams. (you obiously need an even number of teams so / ("no team") is added if odd number) #!/local/bin/perl5 -w use strict; my @teams = qw(A B C D E F); my @list; push @teams, '/' if @teams % 2; for my $round (0 .. @teams-2) { push @teams, splice @teams, 1, 1; @{$list[$round]} = map "$teams[$_]-$teams[@teams-$_-1]", (0 .. @teams / 2 - 1); } for (@list){print "@$_\n"}; -- Tor Fuglerud |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Perl Translation [was Re: [SPOILER] Medium QOTW 1 solution]: 00015, Shlomi Fish |
|---|---|
| Next by Date: | Re: Perl Translation: 00015, Daniel Martin |
| Previous by Thread: | [SPOILER] My Solution to Medium QOTW - Tournament Schedulei: 00015, Shlomi Fish |
| Next by Thread: | [SPOILER] My solution to the tournament scheduler quiz: 00015, Walt Mankowski |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |