-
-
Save sundevilyang/63df48ec1cf7ee9455afcc6a47817f97 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