Last active
November 27, 2016 20:09
-
-
Save lazypower/4ee7ff1cb036e5c914a83907e44d683e 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
#!/usr/bin/env python | |
import random | |
people = ['connor', | |
'seanie', | |
'spencer', | |
'meme', | |
'ken', | |
'tessa', | |
'charles', | |
'jan', | |
'dennis', | |
'matt', | |
'michael'] | |
random.shuffle(people) | |
buying_for = {} | |
def ensure_unique_match(person, match=None): | |
if match is None: | |
match = random.choice(people) | |
while match in person: | |
match = random.choice(people) | |
while match in buying_for.values(): | |
match = random.choice(people) | |
return match | |
for person in people: | |
print('Matching for {}'.format(person)) | |
random_match = ensure_unique_match(person) | |
buying_for[person] = random_match | |
for people in buying_for: | |
print("{} should purchase for {}".format(people, buying_for[people])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment