Created
November 8, 2019 12:13
-
-
Save gkocjan/be0b42a9e9884034492ee9963728e19e to your computer and use it in GitHub Desktop.
Simple secret santa without ifs and fors
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
import random | |
def match_persons(persons): | |
givers = persons.copy() | |
random.shuffle(givers) | |
recipients = givers[1:] + [givers[0]] | |
return zip(givers, recipients) | |
def secret_santa(): | |
for pair in match_persons(['Marek', 'Przemek', 'Michał', 'Kamila']): | |
print(f"Secret santa {pair[0]} buys gift for {pair[1]}") | |
if __name__ == "__main__": | |
secret_santa() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment