Skip to content

Instantly share code, notes, and snippets.

@v3n
Created July 25, 2015 06:38
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 v3n/c427ea8e674af47724fc to your computer and use it in GitHub Desktop.
Save v3n/c427ea8e674af47724fc to your computer and use it in GitHub Desktop.
compute statistics for 2015 NA LCS Playoffs
teams = {
"TSM" => 90,
"C9" => 70,
"TL" => 50,
"TIP" => 30,
"CLG" => 10,
"GV" => 10,
"DG" => 0
}
cp_values = [1000, 90, 70, 40, 20, 20]
playoffs = ["TSM", "TL", "TIP", "CLG", "GV", "DG"]
possibilities = [ ]
# generate permutations
playoffs.permutation.each do |per|
local_order = { }
per.each_with_index do |team, i|
local_order[team] = teams[team] + cp_values[i]
end
# manually add C9 since they're not in playoffs
local_order["C9"] = 70
possibilities << local_order
end
cnt_h = {
"TSM" => 0,
"C9" => 0,
"TL" => 0,
"TIP" => 0,
"CLG" => 0,
"GV" => 0,
"DG" => 0
}
# iterate over permutations
possibilities.each do |poss|
# print valid permutations for team qualifying
poss2 = poss.sort_by { |key, val| val }.reverse.to_h
if poss2.keys[0..2].include? "CLG" then
puts poss
# print poss.keys[0..5].join ", "
end
# sum up each team making it to worlds
teams.keys.each do |team_name|
if poss2.keys[0..2].include? team_name then
cnt_h[team_name] = cnt_h[team_name] + 1
end
end
end
# compute probabilities for each team going to Worlds
cnt_h.each do |team|
puts team[0] + ": " + ((team[1].to_f / 720.to_f) * 100).to_s
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment