This week's book giveaway is in the Kotlin forum.We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
programming forums Java Java JSRs Mobile Certification Databases Caching Books Engineering OS Languages Frameworks Products This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Sheriffs:
Saloon Keepers:
Bartenders:

# A Game every day

David O'Meara
Rancher
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
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 ]

Timmy Marks
Ranch Hand
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
Posts: 18671
Oops - error in recopying from my notes; now fixed above. Thanks.

 It is sorta covered in the JavaRanch Style Guide.