You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

23 lines
371 B

lines = open("input.txt", 'r').read().splitlines()
leng = len(lines)
bits = len(lines[0])
count = [0] * bits
for s in lines:
for i in range(0, bits):
if bool(int(s[i])):
count[i] += 1
gama = 0
epsi = 0
print(count)
for i in range(0, bits):
if count[i] > leng/2:
gama += 2**(bits-i-1)
else:
epsi += 2**(bits-i-1)
print(gama)
print(epsi)
print(gama*epsi)