SHARE
TWEET

Untitled

a guest Dec 16th, 2011 68 Never
  1. def majority(A):
  2.     min = len(A)/2.0
  3.     counts = {}
  4.     for x in A:
  5.         if x in counts:
  6.             counts[x] += 1
  7.         else:
  8.             counts[x] = 1
  9.     a = max(counts.iteritems(), key = lambda x: x[1])
  10.     if a[1] > min:
  11.         print "The winner is:", a[0]
  12.     else:
  13.         print "There is no winner"
RAW Paste Data
Top