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.

24 lines
371 B

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