Want more features on Pastebin? Sign Up, it's FREE!
Guest

voters

By: phillip1882 on Apr 6th, 2012  |  syntax: Python  |  size: 0.83 KB  |  views: 56  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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
clone this paste RAW Paste Data