Skip to content

Instantly share code, notes, and snippets.

@mecampbellsoup
Last active December 24, 2015 12:49
Show Gist options
  • Select an option

  • Save mecampbellsoup/6800190 to your computer and use it in GitHub Desktop.

Select an option

Save mecampbellsoup/6800190 to your computer and use it in GitHub Desktop.
require 'pry'
require 'awesome_print'
# 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=4, num_groups=20)
students.shuffle!
student_groups = []
num_groups.times do
group = []
group_size.times do
group << students.push(students.shift).last
end
student_groups << group
end
student_groups
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"
]
ap create_groups(students, 4, 20)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment