
voters
By:
phillip1882 on
Apr 6th, 2012 | syntax:
Python | size: 0.83 KB | hits: 53 | expires: Never
import random,sys,os
def print_voters(votes):
os.system("CLS")
for i in range(0,30):
for j in range(0,30):
sys.stdout.write(str(votes[i*30+j]))
sys.stdout.write("\n")
voters = []
for i in range(0,900):
voters += [random.randint(0,1)]
print_voters(voters)
i = 0
result = True
while result:
pos = random.randint(0,899)
bitx = random.randint(-1,1)
bity = random.randint(-1,1)
nieghbor = (pos/30+bity)*30 +pos%30+bitx
if nieghbor > 899:
nieghbor = nieghbor-899
try:
voters[pos] = voters[nieghbor]
except IndexError:
print(nieghbor)
i += 1
if i == 30:
print_voters(voters)
i -= 30
result = False
check = voters[0]
for i in range(1,899):
if check != voters[i]:
result = True
break