Skip to content

Instantly share code, notes, and snippets.

@pumpkincouture
Created September 3, 2014 18:54
Show Gist options
  • Save pumpkincouture/6a0bbee7fb12ce0e9256 to your computer and use it in GitHub Desktop.
Save pumpkincouture/6a0bbee7fb12ce0e9256 to your computer and use it in GitHub Desktop.
def assign_random_santa
santa_shuffled = @santa_shuffled.clone
santa_list = @santa_list.clone
santa_list.each do |person|
potential_partner = santa_shuffled [ rand ]
potential = santa_shuffled.select{ |potential_person| person.not_self(potential_person) }
person.assigned_santa = potential [ rand ] unless potential.empty?
santa_shuffled.delete(person.assigned_santa)
end
santa_list
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment