Skip to content

Instantly share code, notes, and snippets.

@bootcoder
Created November 27, 2015 19:07
Show Gist options
  • Save bootcoder/000e30b46e8237165d34 to your computer and use it in GitHub Desktop.
Save bootcoder/000e30b46e8237165d34 to your computer and use it in GitHub Desktop.
advisor_selection
require 'awesome_print'
$student_arr = ["Christopher Mark","Eunice Choi","Jenna Andersen","Jupiter Baudot","Kai Huang","Kim Allen","Mary Engelbrecht","Mike Cerrone","Nathan Park","Paul Etscheit","Rosy Sinclair-Chin(Rosslyn)","Shawn Watson","Andrew Blum","Armani Saldana","Cecilia 'CJ' Joulain","Danielle Cameron","Daniel Woznicki","Deanna Warren","Eran Chazan","Eric Dell'Aringa","Gouron Paul","Isaac Lee","Jeremy Powell","Joseph Marion","Joshua Kim","Kyle Smith","Mark Janzer","Nicole Yee","Ovi Calvo","Peter Wiebe","Steven Broderick","Abraham Clark","Amaar Fazlani","Bernice Anne W Chua","Brian Bensch","Fatma Ocal","Gregory Wehmeier","Jon Clayton","Karla King","Malia Lehrer","Michael Whelpley","Natasha Thapliyal","Nil Thacker","Shawn Spears","Tal Schwartz","Trevor Newcomb","Walter Kerr","William Brinkert","Jamar Gibbs"]
$instructor_arr = ["Hunter", "Shambhavi", "Julian", "Jordan"]
$results_hash = {}
# We want to distribute all students evenly among instructors
# until students_arr is empty
# loop over instructors adding a random student to each
#
def evenly_distrubute_students
$instructor_arr.each do |advisor|
$results_hash[advisor.to_sym] = []
end
until $student_arr.empty?
$instructor_arr.each do |advisor|
$results_hash[advisor.to_sym] << $student_arr.shuffle!.pop if $student_arr.length > 0
end
end
end
evenly_distrubute_students
ap $results_hash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment