Created
February 18, 2014 20:36
-
-
Save allcentury/9079527 to your computer and use it in GitHub Desktop.
Round Robin
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
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