Created
December 10, 2019 19:49
-
-
Save alexanderjlee/813d1a97136e8948d1d4bc3d15adf17a to your computer and use it in GitHub Desktop.
Alex Lee - Family Fridays - groups.rb
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
group_size = ENV['GROUPSIZE'].to_i | |
users = Array.new | |
for u in 1..21 do | |
users.push("Employee_#{u}") | |
end | |
users.shuffle! | |
max_groups = users.length / group_size | |
offset = users.length % group_size | |
group_number = 1 | |
position = 0 | |
for x in users do | |
if group_number <= offset | |
if position < group_size | |
puts "Group #{group_number}: #{x}" | |
position += 1 | |
else | |
puts "Group #{group_number}: #{x}" | |
group_number += 1 | |
position = 0 | |
end | |
else | |
if position < group_size - 1 | |
puts "Group #{group_number}: #{x}" | |
position += 1 | |
else | |
puts "Group #{group_number}: #{x}" | |
group_number += 1 | |
position = 0 | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment