Last active
September 3, 2019 13:51
-
-
Save cantin/a2f0d5e9bd2d82ff0a1f to your computer and use it in GitHub Desktop.
GuangZhou RailsGirs Pair
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
tutors = ["***", "***", "***"] | |
girls = ["***", "***", "***"] | |
number = "To be defined" | |
tutors = tutors.shuffle(random: Random.new(number)) | |
girls = girls.shuffle(random: Random.new(number)) | |
result = Hash.new { |hash, key| hash[key] = [] } | |
tutors.cycle(3).each_with_index do |tutor, i| | |
result[tutor] << (girls[i] || "未配对") | |
end | |
result.each do |key, value| | |
puts "#{key} => #{value.join(", ")}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment