logo       

Re: [QUIZ] Perl 'Medium' QOTW - Tournament Schedule: msg#00005

lang.perl.qotw.discuss

Subject: Re: [QUIZ] Perl 'Medium' QOTW - Tournament Schedule

On Jan 14 David Jones wrote:

> > 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.
>
> Sorry, I just can't parse that sentence.
>
> Clarification, anyone?

allocate_schedule(4)



may return:



[[1,0,3,2],[2,3,0,1],[3,2,1,0]];

For Day one the array is [1,0,3,2].

Team 0 looks at the first entry to see who they play. The first entry in
[1,0,3,2] is a 1, so they play team 1.

Team 1 looks at the second entry to see who they play. The second entry
in [1,0,3,2] is a 0, so they play team 0.

Team 2 looks at the third entry to see who they play. The third entry in
[1,0,3,2] is a 3, so they play team 3.

Team 3 looks at the last entry to see who they play. The last entry in
[1,0,3,2] is a 2, so they play team 2.

For Day two the array is [2,3,0,1] ...

Team 0 and 2 play each other.
Team 1 and 3 play each other.

HTH,

Jim






<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise