Created
December 24, 2016 04:19
-
-
Save colinpollock/953bb39373db04af11f2f2f26e5e5822 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
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) | |
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