|
Re: Perl Translation: msg#00019lang.perl.qotw.discuss
On Wednesday 19 January 2005 13:31, Greg Matheson wrote: > On Wed, 19 Jan 2005, I wrote: > Jeffrey Vinocur's visualization of the problem as n-1 teams > moving about the perimeter of n/2 parallel playing fields, ie all > except the champions who play all their games before the stadium > results in the same solution as the above one, I believe. The outputs of Vinocur's variant, and Zsban Ambrus' one are similar. Thus, I was able to modify (after some tinkering) Ambrus' solution to produce the same results as Vinocur's: <<< use strict; use warnings; sub allocate_schedule { my $n = shift; my $m = $n - 1; my @ret; for my $d (0 .. ($m-1)) { my @day = (); push @day, ($d+1); for my $k (1 .. $m) { if ($k == ($d+1)) { push @day, 0; } else { push @day, (1 + (2*$d+1-$k) % ($m)); } } push @ret, [ @day ]; } return \@ret; } 1; >>> But naturally, this solution no longer makes use of the near and far arrays he allocated. Regards, Shlomi Fish -- --------------------------------------------------------------------- Shlomi Fish shlomif-ik1l9ssToec+JF/nGntIXQ@xxxxxxxxxxxxxxxx Homepage: http://www.shlomifish.org/ Knuth is not God! It took him two days to build the Roman Empire. |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: Perl Translation: 00019, Greg Matheson |
|---|---|
| Next by Date: | [SPOILER] My solution to the tournament scheduler quiz: 00019, Walt Mankowski |
| Previous by Thread: | Re: Perl Translationi: 00019, Greg Matheson |
| Next by Thread: | Re: Perl Translation: 00019, Shlomi Fish |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |