aboutsummaryrefslogtreecommitdiff
path: root/2025/07/b.py
blob: 0a8672e4155b475fa5bda39869e1c253d8480041 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import fileinput
from collections import defaultdict

with fileinput.input() as lines:
	rows = [line[:-1] for line in lines]

pos = {rows[0].find('S'): 1}
for row in rows[1:]:
	newpos = defaultdict(int)
	for p, w in pos.items():
		for pp in [p-1,p+1] if row[p] == '^' else [p]:
			newpos[pp] += w
	pos = dict(newpos)

print(sum(pos.values()))

Generated with cgit - Back to sebastiano.tronto.net