28 lines
619 B
Python
28 lines
619 B
Python
#!/usr/bin/env python3
|
|
|
|
file = [i.rstrip() for i in open("input").readlines()]
|
|
|
|
def gammaepsil(data):
|
|
bufg = []
|
|
bufe = []
|
|
for i in range(len(data[0])):
|
|
one = 0
|
|
zero = 0
|
|
for j in range(len(data)):
|
|
if data[j][i] == "0":
|
|
zero += 1
|
|
else:
|
|
one += 1
|
|
if zero > one:
|
|
bufg.append("0")
|
|
bufe.append("1")
|
|
else:
|
|
bufg.append("1")
|
|
bufe.append("0")
|
|
return [int(''.join(bufg), base=2), int(''.join(bufe), base=2)]
|
|
|
|
|
|
res = gammaepsil(file)
|
|
print(res[0], res[1], res[0]*res[1])
|
|
|