Skip to content

Instantly share code, notes, and snippets.

@gkocjan
gkocjan / secret_santa.py
Created Nov 8, 2019
Simple secret santa without ifs and fors
View secret_santa.py
import random
def match_persons(persons):
givers = persons.copy()
random.shuffle(givers)
recipients = givers[1:] + [givers[0]]
return zip(givers, recipients)
View gifts.py
import random
givers = ['Marek', 'Przemek', 'Michał', 'Kamila']
recipients = givers.copy()
for person in givers:
potential_gift_recipient = [
recipient
for recipient in recipients
if recipient != person
You can’t perform that action at this time.