Skip to content

Instantly share code, notes, and snippets.

@bycoffe
Forked from eyeseast/santa.py
Created December 6, 2010 14:29
Show Gist options
  • Save bycoffe/730355 to your computer and use it in GitHub Desktop.
Save bycoffe/730355 to your computer and use it in GitHub Desktop.
#!/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)
print
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment