Last active
December 5, 2018 10:11
-
-
Save reitzig/3a2c97274a6ed09bf049092b0d67e76d to your computer and use it in GitHub Desktop.
Invite people to a Secret Santa without you knowing who draws whom (sketch)
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
#!/usr/bin/env ruby | |
participants = [ | |
{ :name => "Santa", :email => "[email protected]" }, | |
{ :name => "Rudolf", :email => "[email protected]" }, | |
{ :name => "Ruprecht", :email => "[email protected]" } | |
] | |
def assign_gifts(folks) | |
perm = (0...folks.size).to_a.shuffle | |
perm.zip(perm.rotate(1)).each { |pair| | |
send_mail(folks[pair[0]][:email], folks[pair[1]][:name]) | |
} | |
end | |
def send_mail(to, gift_to) | |
puts "Tell #{to} to prepare a 🔒-🎅 🎁 for #{gift_to}" | |
# Real implementation e.g. with: https://jerodsanto.net/2009/02/a-simple-ruby-method-to-send-emai/ | |
end | |
assign_gifts(participants) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment