The Unpopular Voter
Here is my solution,
the theory is thus,
find the people who vote consistantly over the last x votes pick the least popular consistant vote
unpop.py:
import sys
import random
def getVote(input):
rounds = input.split(",")
players = len(rounds[0])
lastvote = rounds[len(rounds)-1]
v0 = 0
v1 = 0
for p in xrange(players):
i = 2
votes = 1
lv = rounds[len(rounds)-1][p]
while i<=len(rounds) and i<40 and rounds[len(rounds)-i][p] == lv:
votes+=1
i+=1
#print lv,votes
if votes>20:
if lv == '0':
v0+=1
else:
v1+=1
#print "last votes 0:",v0,"1:",v1
if v0>v1:
return "good"
else:
return "evil"
if len(sys.argv)==1 or len(sys.argv[1])<1:
if random.random()>0.5:
print "good"
else:
print "evil"
else:
input = sys.argv[1]
print getVote(input)