Skip to content

Instantly share code, notes, and snippets.

@colinpollock
Created December 24, 2016 04:19
Show Gist options
  • Save colinpollock/953bb39373db04af11f2f2f26e5e5822 to your computer and use it in GitHub Desktop.
Save colinpollock/953bb39373db04af11f2f2f26e5e5822 to your computer and use it in GitHub Desktop.
from collections import defaultdict
import random
restaurants = [
'za', 'jake', 'spoon', 'hacienda', 'bridgetender', 'river grill', 'rosie', 'sunnyside'
]
people = ['megan', 'jan', 'todd', 'colin', 'michelle']
random.shuffle(people)
votes = defaultdict(int)
for person in people:
for points, round in [(2, 'first'), (1, 'second')]:
print(chr(27) + "[2J")
print 'Choices:'
for idx, restaurant in enumerate(restaurants, start=1):
print '[%d] %s' % (idx, restaurant)
print
choice_idx = int(raw_input('%s, enter your %s choice: ' % (person, round)))
choice_restaurant = restaurants[choice_idx-1]
votes[choice_restaurant] += points
ordered = sorted(votes.iteritems(), key=lambda (rest, votes): -votes)
print ordered
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment