Created
September 1, 2014 14:50
-
-
Save pumpkincouture/5eff5c7de03ec6d3e02f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
def assign_random_santa | |
#if @santa_list.length%2 == 0 | |
@santa_list.each do |person| | |
potential_partner = @santa_shuffled[ rand ] | |
potential = @santa_list.select{|person| person.not_self(potential_partner) && person.legit_santa(potential_partner } | |
# person.assigned_santa = potential_partner if person.not_self(potential_partner) && person.legit_santa(potential_partner) | |
# potential_partner.assigned_santa = person | |
person.assigned_santa = potential [ rand ] unless potential.empty? | |
#delete if successful assignment | |
# @santa_shuffled.delete(potential_partner) | |
#delete from duplicated santa shuffled list | |
end | |
@santa_list | |
# else | |
# puts "Not enough people to pair!" | |
# return false | |
# end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment