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