Skip to content

Instantly share code, notes, and snippets.

@allcentury
Created February 18, 2014 20:36
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 allcentury/9079527 to your computer and use it in GitHub Desktop.
Save allcentury/9079527 to your computer and use it in GitHub Desktop.
Round Robin
studentsarray = ["Anthony", "Greg", "Dan", "Rohan", "Lydia", "Lee", "Chris", "Charlie", "Barry", "Julissa", "Victor", "Arnold"]
def groupsplit(array)
group1 = []
group2 = []
array.each_with_index do |x, i|
if i >= (array.length / 2)
group1 << x
else
group2 << x
end
end
return group1, group2
end
groups = groupsplit(studentsarray)
days = 0
while days < 13
groups[1] << groups[0].pop
groups[0].insert(1,groups[1].shift)
puts "Day #{days+1}"
ctr = 0
while ctr < groups[0].length
puts "#{groups[0][ctr]} :: #{groups[1][ctr]}"
ctr += 1
end
puts "-------"
days += 1
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment