I have some questions about this problem.

First http://www.crowsdarts.com/brackets/playoff-chart.html, for 5 
teams, is the output correct?  It gives the following match-ups for the 
1st round:
1 vs. bye
4 vs. 5
2 vs. 3

Wouldn't the correct answer be:
1 vs. bye
5 vs. 2
4 vs. 3

Also, are there allowed to be any "byes" in the 2nd or greater rounds?

Thanks,
Dan

Ruby Quiz wrote:
> The three rules of Ruby Quiz:
> 
> 1.  Please do not post any solutions or spoiler discussion for this quiz until
> 48 hours have passed from the time on this message.
> 
> 2.  Support Ruby Quiz by submitting ideas as often as you can:
> 
> http://www.rubyquiz.com/
> 
> 3.  Enjoy!
> 
> Suggestion:  A [QUIZ] in the subject of emails about the problem helps everyone
> on Ruby Talk follow the discussion.  Please reply to the original quiz message,
> if you can.
> 
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
> 
> by Demetrius Nunes
> 
> In a single-elimination tournament, there is usually a previously established
> ranking for the participating players or teams, such as that the best players or
> teams are matched against the worst ones. This is done this way so there is a
> higher chance for the top players/teams to meet in the final.
> 
> For example, in a small 8-player tournament, there would be 3 rounds. This first
> round would be setup like this:
> 
> 	Round 1
> 	1 x 8
> 	2 x 7
> 	3 x 6
> 	4 x 5
> 
> This is easy enough. The tough part is arranging the pairing for the following
> rounds respecting the best vs worst rule, so, imagining that all the favorites
> won their games, we would have 1x4 and 2x3 in round 2 and then finally 1x2 in
> the final. For this to happen, the tournament would have to be arranged this
> way:
> 
> 	R1  R2  R3
> 	============
> 	1
> 	---
> 	   |---
> 	---    |
> 	8      |
> 	       |---
> 	4      |   |
> 	---    |   |
> 	   |---    |
> 	---        |
> 	5          |
> 	           |----
> 	2          |
> 	---        |
> 	   |---    |
> 	---    |   |
> 	7      |   |
> 	       |---
> 	3      |
> 	---    |
> 	   |---
> 	---
> 	6
> 
> If the numbers of players/teams is not a potency of 2, then the top players
> would have a "bye" in the first round, so, a 6-player draw would go like this:
> 
> 	R1  R2  R3
> 	============
> 	1
> 	---
> 	   |---
> 	---    |
> 	bye    |
> 	       |---
> 	4      |   |
> 	---    |   |
> 	   |---    |
> 	---        |
> 	5          |
> 	           |----
> 	2          |
> 	---        |
> 	   |---    |
> 	---    |   |
> 	bye    |   |
> 	       |---
> 	3      |
> 	---    |
> 	   |---
> 	---
> 	6
> 
> So, this quiz is about writing a single-elimination tournament generator for any
> number of players/teams obeying the best vs worst rule in all rounds.
> 
> For a quick look at correct answers see this "got-the-job-done" javascript/html
> implementation at:
> 
> 	http://www.crowsdarts.com/brackets/playoff-chart.html
> 
> We are looking for correct data modeling and calculation, not for correct
> presentation output of the tournament draw, but it would be nice to implement a
> #to_s output like the ones seen above (or even better: how about a beautiful
> RMagick generated image?!). In all cases, keep the model and presentation
> cleanly separated.
> 
>