Created
July 29, 2011 02:13
-
-
Save joshmarshall/1112997 to your computer and use it in GitHub Desktop.
Twitter Winner Chooser
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
""" This proves that there was no money under the table. """ | |
import random | |
import sys | |
from collections import Counter | |
def main(): | |
""" Pick one of the sys args """ | |
assert len(sys.argv) > 1 | |
names = sys.argv[1:] | |
scores = Counter() | |
# because doing random.choice() once is just boring | |
for i in range(100): | |
name = random.choice(names) | |
scores[name] += 1 | |
scores = [(name, val) for name, val in scores.iteritems()] | |
scores.sort(key=lambda x: x[1], reverse=True) | |
for name, score in scores: | |
print name, score | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment