blob: 48a8f2adcfcfb17d285ee50b12f6cd11d50a9e35 (
plain)
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
|
#!/usr/bin/env python3
from fileinput import input
from functools import partial, reduce
lines = [line.strip() for line in input()]
bs = {lines[0].index("S")}
silver = 0
def split(t: int, c: int) -> set[int]:
global silver
if lines[t][c] == "^":
silver += 1
return {c - 1, c + 1}
return {c}
for t, _ in enumerate(lines):
bs = reduce(set.union, map(partial(split, t), bs))
gold = 0
print("silver:", silver)
print("gold:", gold)
|