File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programming Diversions and the fly likes A Game every day Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Other » Programming Diversions
Bookmark "A Game every day" Watch "A Game every day" New topic
Author

A Game every day

David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

I was thinking about this over the weekend, since we have a tri-nations one-day Cricket competition running between Australia, India and Zimbabwe.
Aust and India played on Friday, but then I had to wait till Sunday for Australia and Zimbabwe to play in the next game!
Q: How many teams (greater than 2 ) do you need in a competition so that a single game can be played every day, every team plays every other team, and no team plays consecutive games (ie on consecutive days)?
Q2: How is this arranged? (Proof required, since I don't have the slution stashed somewhere)
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
Five.
If there are 3 teams, then two must play the first day. On the second day, the remaining team is the only one eligible to play, because the other two teams played just one day ago. So 3 teams is impossible.
If there are 4 teams, then let the teams who play on day 1 be known as A and B. On day 2, the remaining teams must play - call them C and D. On day 3, only A and B are eligible to play, and they've already played each other, so no solution is possible for 4 teams.
If there are 5 teams, they can play a schedule as follows:
1: A-B
2: C-D
3: E-A
4: B-C
5: D-E
6: A-C
7: B-D
8: C-E
9: D-A
10: E-B
That covers all 10 possible combinations of 5 elements taken 2 at a time (C(5, 2) = 5!/(2!(5-2)!) = 10), with no teams playing on consecutive days.
[ January 11, 2004: Message edited by: Jim Yingst ]

"I'm not back." - Bill Harding, Twister
Timmy Marks
Ranch Hand

Joined: Dec 01, 2003
Posts: 226
Yes, but the last 4 rounds need to be changed around a little. For example, 8, 10, 7, 9
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
Oops - error in recopying from my notes; now fixed above. Thanks.
 
GeeCON Prague 2014
 
subject: A Game every day