26 lines
666 B
Python
Executable File
26 lines
666 B
Python
Executable File
#!/usr/bin/env python3
|
|
from useful import *
|
|
|
|
def tpl(l):
|
|
return [int(c) for c in l]
|
|
|
|
def makenum(l):
|
|
return int(''.join(str(n) for n in l), 2)
|
|
|
|
def nextcol(a, i=0, crit=lambda a, b: a == b):
|
|
if len(a) <= 1:
|
|
return a[0]
|
|
counts = np.bincount(a.T[i])
|
|
most_common = 1 - counts[::-1].argmax() # like argmax but takes 1 if equal
|
|
return nextcol(np.asarray([c for c in a if crit(c[i], most_common)]), i+1, crit)
|
|
|
|
with open(0) as f:
|
|
|
|
lines = [l.strip() for l in f.readlines()]
|
|
t = [tpl(l) for l in lines]
|
|
|
|
a = np.asarray(t)
|
|
oxy = nextcol(a)
|
|
co2 = nextcol(a, crit=lambda a, b: a != b)
|
|
print(makenum(oxy) * makenum(co2))
|