[Tutor] A (not so) simple question? Round Robin
Adam Gordon
adam0@tsn.cc
Sun, 17 Jun 2001 15:51:41 +1000
This is a multi-part message in MIME format.
------=_NextPart_000_0013_01C0F745.66CBA4C0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hey Guys!
I am just starting to learn python (after hearing my friend praise it =
like a religion :) and thought I'd try out a few classic problems to =
help the learning process.
So, I went to Useless Python to check out the challenges, and then =
went to the High School comp section. I went to the 2000 open =
competition and looked for some fun problems. One which caught my eye =
was a Round Robin problem - didn't look too hard or too easy.
But, for the life of me I cannot do it! I've spent quite some time =
mulling it over but still an elegant solution eludes me...here is a copy =
of the problem as found on the website (here =
http://www.cse.unsw.edu.au/~progcomp/pastComps/00prelim/prelim.phtml).
##start task
Task 5 - Round Robin
Description
n teams are to play each other in a competition. In each round each team =
plays exactly one other team. We wish to have as few rounds as possible. =
Write a program which, given an even number n, produces a "draw table" =
showing which team plays which team in each round. It is to take the =
minimum possible number of rounds. If more than one such draw table is =
possible your program may return whichever you wish.=20
For example here is an 4 player draw table=20
A B C D
A 1 2 3
B 1 3 2
C 2 3 1
D 3 2 1
The letters represent the four teams, the numbers say which round each =
pair of teams is playing.=20
Test Data
Number of teams =20
4 =20
6 =20
8 =20
10 =20
Output
Match the format of the output in the example above.=20
Where there is more than one "draw table" you may return whichever you =
wish.=20
Constraints
You may assume the input is even.=20
##end task
I apologize to anybody with a non-html friendly e-mail client for =
spamming them with gibberish :)
Thanks in advance,
Adam.
------=_NextPart_000_0013_01C0F745.66CBA4C0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 5.50.4611.1300" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>
<DIV> Hey Guys!</DIV>
<DIV> </DIV>
<DIV> I am just starting to learn python (after hearing my friend =
praise=20
it like a religion :) and thought I'd try out a few classic =
problems to=20
help the learning process.</DIV>
<DIV> So, I went to Useless Python to check out the challenges, =
and then=20
went to the High School comp section. I went to the 2000 open =
competition=20
and looked for some fun problems. One which caught my eye was a =
Round=20
Robin problem - didn't look too hard or too easy.</DIV>
<DIV> But, for the life of me I cannot do it! I've spent =
quite some=20
time mulling it over but still an elegant solution eludes me...here is a =
copy of=20
the problem as found on the website (here <A=20
href=3D"http://www.cse.unsw.edu.au/~progcomp/pastComps/00prelim/prelim.ph=
tml">http://www.cse.unsw.edu.au/~progcomp/pastComps/00prelim/prelim.phtml=
</A>).</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>##start task</DIV>
<DIV>
<H1 align=3Dcenter>Task 5 - Round Robin</H1>
<H2>Description</H2>
<P><I>n</I> teams are to play each other in a competition. In each =
<I>round</I>=20
each team plays exactly one other team. We wish to have as few rounds as =
possible.=20
<P>Write a program which, given an even number <I>n</I>, produces a =
"draw table"=20
showing which team plays which team in each round. It is to take the =
minimum=20
possible number of rounds. If more than one such draw table is possible =
your=20
program may return whichever you wish.=20
<P>For example here is an 4 player draw table <PRE> A B C D
A 1 2 3
B 1 3 2
C 2 3 1
D 3 2 1
</PRE>
<P>The letters represent the four teams, the numbers say which round =
each pair=20
of teams is playing.=20
<H3>Test Data</H3>
<TABLE border=3D1>
<TBODY>
<TR>
<TH>Number of teams=20
<TR>
<TD>4=20
<TR>
<TD>6=20
<TR>
<TD>8=20
<TR>
<TD>10 </TD></TR></TBODY></TABLE>
<H3>Output</H3>Match the format of the output in the example above.=20
<P>Where there is more than one "draw table" you may return whichever =
you wish.=20
<H3>Constraints</H3>You may assume the input is even. </DIV>
<DIV> </DIV>
<DIV>##end task</DIV>
<DIV> </DIV>
<DIV> I apologize to anybody with a non-html friendly e-mail =
client for=20
spamming them with gibberish :)</DIV>
<DIV> </DIV>
<DIV> Thanks in advance,</DIV>
<DIV> Adam.</DIV></FONT></DIV></BODY></HTML>
------=_NextPart_000_0013_01C0F745.66CBA4C0--