Skip to content

Instantly share code, notes, and snippets.

@DRMacIver
Forked from Zarkonnen/maj.py
Last active December 13, 2015 22:39
Show Gist options
  • Save DRMacIver/4985887 to your computer and use it in GitHub Desktop.
Save DRMacIver/4985887 to your computer and use it in GitHub Desktop.
# Naive majority judgement implementation. Bigger numbers are better.
def majority_ranking(a):
a = sorted(a)
while a:
x = a[len(a) / 2]
del a[len(a) / 2]
yield x
def maj_cmp(a, b):
return list(majority_ranking(a)) < list(majority_ranking(b))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment