Twelve Angry Men

#!/usr/bin/python

jurors = [0,"guilty","guilty","guilty","guilty",
          "guilty","guilty","guilty","guilty",
          "guilty","guilty","guilty","guilty"]
seed = 0.67130678058407;

def switch (j):
    global jurors
    if (jurors[j]=="guilty"):
        jurors[j]="not guilty"
    else:
        jurors[j]="guilty"

def get_verdict():
    foreman_verdict=jurors[0]
    for j in jurors[1:]:
        if (foreman_verdict != j):
            return None
    return foreman_verdict
       
def random():
    global seed
    new_seed=13*seed
    seed=new_seed-int(new_seed)
    return int(new_seed)

while True:
    switch(random())
    verdict = get_verdict()
    if verdict is not None:
        break
   
print "Verdict is",verdict
Vote up this code0