Skip to content

Instantly share code, notes, and snippets.

@sebabelmar
Last active August 29, 2015 14:01
Show Gist options
  • Save sebabelmar/1b5b897589fe91467082 to your computer and use it in GitHub Desktop.
Save sebabelmar/1b5b897589fe91467082 to your computer and use it in GitHub Desktop.
Random Gangs Creator
FENCE_LIZARDS = [
"Adam Dziuk",
"Adam Ryssdal",
"Aki Suzuki",
"Allison Wong",
"Andra Lally",
"Anup Pradhan",
"CJ Jameson",
"Christiane Kammerl",
"Christopher Aubuchon",
"Clark Hinchcliff",
"Devin A Johnson",
"Dominick Oddo",
"Dong Kevin Kang",
"Eiko Seino",
"Eoin McMillan",
"Hunter T. Chapman",
"Jacob Persing",
"Jon Pabico",
"Joshua Rosaaen",
"Nadia Koroleva",
"Parjam Davoody",
"Renee Schaaf",
"Samuel Davis",
"Sebastian Belmar",
"Shawn Seibert",
"William Butler Bushyhead",
"Yuzu Saijo"
]
def gang_creator(cohort, *boots_per_gang)
raise("Check your boots per gang!") if cohort.length != boots_per_gang.inject(:+)
number_of_gangs = boots_per_gang.length
gangs_of_the_week = {}
counter = 1
# Shuffle the cohort and boots_per_gang
cohort_shuffled = cohort.shuffle
boots_per_gang_shuffled = boots_per_gang.shuffle
# Creates a Hash of group_number as keys and boots as values
number_of_gangs.times do
gangs_of_the_week["gang_#{counter}"] = cohort_shuffled.pop(boots_per_gang_shuffled.pop)
counter += 1
end
#Prints not to fancy
gangs_of_the_week.each {|gangs, gang| puts "#{gangs}: \n #{gang}" }
raise("This is not working!!!!!") if gangs_of_the_week.values.flatten.sort != cohort.sort
end
gang_creator(FENCE_LIZARDS, 7,7,7,6)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment