-
Notifications
You must be signed in to change notification settings - Fork 0
/
13.py
executable file
·59 lines (46 loc) · 1.17 KB
/
13.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env pypy3
# 3/11
from util import *
if len(sys.argv) == 1:
sys.stdin = open(__file__.replace("py", "in"))
pats = sys.stdin.read().split("\n\n")
res = 0
for pat in pats:
pat = lines(pat)
opat = pat
mul = 100
prev = None
for _ in range(2):
H = len(pat)
for y in range(1, H):
a = pat[:y]
b = pat[y:]
if all(x == y for x, y in zip(a[::-1], b)):
# res += mul * y
assert prev is None
prev = mul, y
# nwork.add((y, mul))
break
mul = 1
pat = rotate(pat, 3)
pat = opat
mul = 100
prev = None
for _ in range(2):
H = len(pat)
for y in range(1, H):
a = pat[:y]
b = pat[y:]
wrongs = 0
for x, aaa in zip(a[::-1], b):
for z, w in zip(x, aaa):
wrongs += z != w
if wrongs == 1:
res += mul * y
assert prev is None
prev = mul, y
# nwork.add((y, mul))
break
mul = 1
pat = rotate(pat, 3)
prints(res)