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

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

t = [1 if x == 'S' else 0 for x in rows[0]]
for row in rows[1:]:
	next = [0] * len(row)
	for i in range(len(row)):
		if row[i] == '^':
			next[i-1] += t[i]
			next[i+1] += t[i]
		else:
			next[i] += t[i]
	t = next

print(sum(t))

Generated with cgit - Back to sebastiano.tronto.net