This commit is contained in:
basicbonobo 2023-12-14 07:55:03 +01:00
parent 9d9dc7871b
commit 115d295589
3 changed files with 1387 additions and 0 deletions

1349
input13 Normal file

File diff suppressed because it is too large Load Diff

15
test13 Normal file
View File

@ -0,0 +1,15 @@
#.##..##.
..#.##.#.
##......#
##......#
..#.##.#.
..##..##.
#.#.##.#.
#...##..#
#....#..#
..##..###
#####.##.
#####.##.
..##..###
#....#..#

23
thirteen.py Executable file
View File

@ -0,0 +1,23 @@
#!/usr/bin/env python3
from useful import *
def is_mirror(pic, axis):
a = pic[:axis]
b = pic[i:i*2][::-1]
c = a == b
return c.all()
ms = [np.array([[c == '#' for c in l] for l in p.strip().split()]) for p in pgphs(open(0).read())]
score = 0
for m in ms:
for tran, scoretran in ((lambda a: a, lambda n, h: n * 100),
(lambda a: a[::-1], lambda n, h: (h - n) * 100),
(lambda a: a.T, lambda n, h: n),
(lambda a: a.T[::-1], lambda n, h: h - n),):
height = tran(m).shape[0]
for i in range(1, height // 2 + 1):
if is_mirror(tran(m), i):
#ic(tran, i, draw(m))
score += scoretran(i, height)
print(score)