-
-
Save bycoffe/730355 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/python | |
''' | |
Python-based gift exchange randomizer. | |
Step through a list of people and, for each member of that list, | |
select someone else to be a recipient of their gift. That recipient: | |
A) Must not be themselves (no self-gifting) | |
B) Must not already have been assigned as a recipient | |
''' | |
from collections import deque | |
import random | |
# Participants | |
people = ['John','Jamie','Avis','Jim','Amy','Scot'] | |
random.shuffle(people) | |
receivers = deque(people) | |
receivers.rotate(len(receivers)-1) | |
for giver, receiver in zip(people, receivers): | |
print '%s gives to %s' % (giver, receiver) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment