Skip to content

Instantly share code, notes, and snippets.

@Zarkonnen
Created February 19, 2013 13:24
Show Gist options
  • Save Zarkonnen/4985834 to your computer and use it in GitHub Desktop.
Save Zarkonnen/4985834 to your computer and use it in GitHub Desktop.
Naive majority judgement
# 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