aboutsummaryrefslogtreecommitdiff
path: root/2025/07/b2.py
diff options
context:
space:
mode:
Diffstat (limited to '2025/07/b2.py')
-rw-r--r--2025/07/b2.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/2025/07/b2.py b/2025/07/b2.py
new file mode 100644
index 0000000..b77188c
--- /dev/null
+++ b/2025/07/b2.py
@@ -0,0 +1,17 @@
1import fileinput
2
3with fileinput.input() as lines:
4 rows = [line[:-1] for line in lines]
5
6t = [1 if x == 'S' else 0 for x in rows[0]]
7for row in rows[1:]:
8 next = [0] * len(row)
9 for i in range(len(row)):
10 if row[i] == '^':
11 next[i-1] += t[i]
12 next[i+1] += t[i]
13 else:
14 next[i] += t[i]
15 t = next
16
17print(sum(t))

Generated with cgit - Back to sebastiano.tronto.net