Skip to content

Instantly share code, notes, and snippets.

@kylemac
Created June 7, 2010 23:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kylemac/91e1f1c392bed8074531 to your computer and use it in GitHub Desktop.
Save kylemac/91e1f1c392bed8074531 to your computer and use it in GitHub Desktop.

The Rules

  1. 32 teams split into 4 teirs (by their FIFA ranking)
  2. 8 entries
  3. Each entry is randomly assigned 1 team per tier
require 'yaml'
@teams = YAML::load(File.open('teams.yaml'))
@players = %w[Player1 Player2 Player3 Player4 Player5 Player6 Player7 Player8]
results = Hash.new
players = @players.sort_by{rand}
players.each_with_index do |p, i|
results[p] = Array[@teams['teir_one'][i]]
end
second = @players.sort_by{rand}
second.each_with_index do |p, i|
results[p] << @teams['teir_two'][i]
end
third = @players.sort_by{rand}
third.each_with_index do |p, i|
results[p] << @teams['teir_three'][i]
end
fourth = @players.sort_by{rand}
fourth.each_with_index do |p, i|
results[p] << @teams['teir_four'][i]
end
p results
teir_one:
- Brazil
- Spain
- England
- Netherlands
- Argentina
- Germany
- Chile
- Portugal
teir_two:
- Uruguay
- Serbia
- Italy
- France
- Ivory Coast
- United States
- Mexico
- Paraguay
teir_three:
- Denmark
- Cameroon
- Australia
- South Korea
- Honduras
- Slovenia
- Nigeria
- Switzerland
teir_four:
- Ghana
- Greece
- Japan
- Slovakia
- South Africa
- Algeria
- North Korea
- New Zealand
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment