Skip to content

Instantly share code, notes, and snippets.

@lazypower
Last active November 27, 2016 20:09
Show Gist options
  • Save lazypower/4ee7ff1cb036e5c914a83907e44d683e to your computer and use it in GitHub Desktop.
Save lazypower/4ee7ff1cb036e5c914a83907e44d683e to your computer and use it in GitHub Desktop.
#!/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