Created
March 18, 2014 19:35
-
-
Save tomwhoiscontrary/9627711 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#! /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