Created
May 1, 2015 12:56
-
-
Save codeodor/e894033665a590784d76 to your computer and use it in GitHub Desktop.
tournament seeding
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
teams = (1..16).to_a | |
# => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16] | |
games = (0..7).inject([]){|g, i| g << [teams[i], teams[-i-1]] } | |
# => [[1, 16], [2, 15], [3, 14], [4, 13], [5, 12], [6, 11], [7, 10], [8, 9]] | |
# so now, how do I transform that to: | |
# => [[1, 16], [8, 9], [5, 12], [4, 13], [6, 11], [3, 14], [7, 10], [2, 15]] | |
# In essence, I have the teams already sorted into the games of who plays who in this round. | |
# But I want to order the games so they appear next to who will play the winners of this round in the next round. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment