Skip to content

Instantly share code, notes, and snippets.

@tomwhoiscontrary
Created March 18, 2014 19:35
Show Gist options
  • Save tomwhoiscontrary/9627711 to your computer and use it in GitHub Desktop.
Save tomwhoiscontrary/9627711 to your computer and use it in GitHub Desktop.
#! /usr/bin/env python
import sys
labels = sys.argv[1:]
rows = map(lambda strings: map(int, strings), map(str.split, map(str.rstrip, sys.stdin.readlines())))
def vote(row):
assert len(row) == len(labels)
return sorted(zip(row, labels))
def stringify(vote):
tokens = [('', vote[0][1])] + [('=' if vote[i - 1][0] == vote[i][0] else '>', vote[i][1]) for i in xrange(1, len(vote))]
return ' '.join(map(' '.join, tokens)).lstrip()
votes = map(vote, rows)
for vote in votes:
print stringify(vote)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment