blob: fc17d79cf8ba99e87eba990cdf31bedad87653bd (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
B = [l.splitlines() for l in open("input").read().strip().split("\n\n")]
def solve(ls, delta):
for row in range(1, len(ls)):
errors = 0
for prev, next in zip(ls[:row][::-1], ls[row:]):
for p, n in zip(prev, next):
if p == n:
continue
errors += 1
if errors == delta:
return row
return 0
print(sum(solve([*zip(*ls)], 0) + solve(ls, 0) * 100 for ls in B))
print(sum(solve([*zip(*ls)], 1) + solve(ls, 1) * 100 for ls in B))
|