Created
October 11, 2013 15:20
-
-
Save TrevMcKendrick/6936553 to your computer and use it in GitHub Desktop.
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
# create a method called create_groups that, given an array of student names, | |
# a group size, and a number of groups, will return an array of groups of | |
# of students with no student in adjacent groups | |
def create_groups(students,group_size,group_count) | |
new_student_array = [] | |
i = 0 | |
j = 0 | |
extras = students.size % group_count | |
while i < group_count do | |
new_student_array << [] | |
puts "i at beginning of loops: #{i}" | |
group_size.times do |student| | |
new_student_array[i] << students[j] | |
j += 1 | |
puts "i after j+1: #{i}" | |
end | |
i += 1 | |
puts "i after doing i+= #{i}" | |
end | |
until j > students.size do | |
puts j | |
new_student_array[i-1] << students[j] | |
j += 1 | |
end | |
students.each_with_index do |student_name,index| | |
end | |
new_student_array.shuffle | |
end | |
students = [ | |
"Alex Chiu", | |
"Amanda Himmelstoss", | |
"Anders Ramsay", | |
"Bana Malik", | |
"Brendan Manley", | |
"Charlotte Chang", | |
"Christopher Lee", | |
"Daniel Chang", | |
"David Bella", | |
"Edina Vath", | |
"Emily Xie", | |
"Greg Eng", | |
"Ian Miller", | |
"Iris Lee", | |
"Ivan Brennan", | |
"James Tong", | |
"Jeanne Roniger", | |
"Joe O'Conor", | |
"John Richardson", | |
"Joshua Scaglione", | |
"Kyle Shike", | |
"Logan Hasson", | |
"Manuel Neuhauser", | |
"Margaret Lee", | |
"Matt Campbell", | |
"Michael Polycarpou", | |
"Mike Spangler", | |
"Raymond Gan", | |
"Rosanne Hoyem", | |
"Sam Yang", | |
"Samuel Owens", | |
"Saron Yitbarek", | |
"Scott Luptowski", | |
"Vivian Zhang", | |
"Sonja Hall", | |
"Stephanie Oh", | |
"Theo Vora", | |
"Thomas Surgent", | |
"Tiffany Peon", | |
"Trevor McKendrick", | |
"Vinney Cavallo" | |
] | |
puts create_groups(students,10,4).inspect |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment