Skip to content

Instantly share code, notes, and snippets.

@cantin
Last active September 3, 2019 13:51
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save cantin/a2f0d5e9bd2d82ff0a1f to your computer and use it in GitHub Desktop.
Save cantin/a2f0d5e9bd2d82ff0a1f to your computer and use it in GitHub Desktop.
GuangZhou RailsGirs Pair
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