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

with fileinput.input() as lines:
	rows = [line[:-1] for line in lines]
	pos = {rows[0].find('S'): 1}

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

print(sum(pos.values()))

Generated with cgit - Back to sebastiano.tronto.net