Created
February 19, 2013 13:24
-
-
Save Zarkonnen/4985834 to your computer and use it in GitHub Desktop.
Naive majority judgement
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
# Naive majority judgement implementation. Bigger numbers are better. | |
def low_med(a): | |
return a[len(a) / 2] | |
def maj_cmp(a, b): | |
a = sorted(a) | |
b = sorted(b) | |
while low_med(a) == low_med(b): | |
if len(a) == 1 or len(b) == 1: | |
return 0 | |
del a[len(a) / 2] | |
del b[len(b) / 2] | |
return low_med(b) - low_med(a) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment