aboutsummaryrefslogtreecommitdiff
path: root/2025/07/b.py
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2025-12-07 06:34:41 +0100
committerSebastiano Tronto <sebastiano@tronto.net>2025-12-07 06:34:41 +0100
commitaa7ddad8c6949b5dfb7a4c77b49c5e65ae5aa782 (patch)
treebcebe015f5764ed45d2c6aa6a22a3b3cf88cb3e3 /2025/07/b.py
parentbe683b101393d3566261c9cc10351398bd2e1b6c (diff)
downloadaoc-aa7ddad8c6949b5dfb7a4c77b49c5e65ae5aa782.tar.gz
aoc-aa7ddad8c6949b5dfb7a4c77b49c5e65ae5aa782.zip
Day 7 2025
Diffstat (limited to '2025/07/b.py')
-rw-r--r--2025/07/b.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/2025/07/b.py b/2025/07/b.py
new file mode 100644
index 0000000..41c0db0
--- /dev/null
+++ b/2025/07/b.py
@@ -0,0 +1,15 @@
1import fileinput
2
3with fileinput.input() as lines:
4 rows = [line[:-1] for line in lines]
5 pos = {rows[0].find('S'): 1}
6
7for row in rows[1:]:
8 newpos = {}
9 for p, w in pos.items():
10 for pp in [p-1,p+1] if row[p] == '^' else [p]:
11 t = newpos.get(pp, 0)
12 newpos[pp] = t + w
13 pos = dict(newpos)
14
15print(sum(pos.values()))

Generated with cgit - Back to sebastiano.tronto.net