Advertisement
phillip1882

voters

Apr 6th, 2012
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.83 KB | None | 0 0
  1. import random,sys,os
  2.  
  3. def print_voters(votes):
  4.    os.system("CLS")
  5.    for i in range(0,30):
  6.       for j in range(0,30):
  7.          sys.stdout.write(str(votes[i*30+j]))
  8.       sys.stdout.write("\n")
  9. voters = []
  10. for i in range(0,900):
  11.    voters += [random.randint(0,1)]
  12.  
  13. print_voters(voters)
  14. i = 0
  15. result = True
  16. while result:
  17.    pos = random.randint(0,899)
  18.    bitx = random.randint(-1,1)
  19.    bity = random.randint(-1,1)
  20.    nieghbor = (pos/30+bity)*30 +pos%30+bitx
  21.    if nieghbor > 899:
  22.       nieghbor = nieghbor-899
  23.    try:
  24.       voters[pos] = voters[nieghbor]
  25.    except IndexError:
  26.       print(nieghbor)
  27.    i += 1
  28.    if i == 30:
  29.       print_voters(voters)
  30.       i -= 30
  31.       result = False
  32.       check = voters[0]
  33.       for i in range(1,899):
  34.          if check != voters[i]:
  35.             result = True
  36.             break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement