Skip to content

Instantly share code, notes, and snippets.

@joshmarshall
Created July 29, 2011 02:13
Show Gist options
  • Save joshmarshall/1112997 to your computer and use it in GitHub Desktop.
Save joshmarshall/1112997 to your computer and use it in GitHub Desktop.
Twitter Winner Chooser
""" 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