diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2025-12-07 06:34:41 +0100 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2025-12-07 06:34:41 +0100 |
| commit | aa7ddad8c6949b5dfb7a4c77b49c5e65ae5aa782 (patch) | |
| tree | bcebe015f5764ed45d2c6aa6a22a3b3cf88cb3e3 /2025/07/a.py | |
| parent | be683b101393d3566261c9cc10351398bd2e1b6c (diff) | |
| download | aoc-aa7ddad8c6949b5dfb7a4c77b49c5e65ae5aa782.tar.gz aoc-aa7ddad8c6949b5dfb7a4c77b49c5e65ae5aa782.zip | |
Day 7 2025
Diffstat (limited to '2025/07/a.py')
| -rw-r--r-- | 2025/07/a.py | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/2025/07/a.py b/2025/07/a.py index 5fdb11b..0e13b75 100644 --- a/2025/07/a.py +++ b/2025/07/a.py | |||
| @@ -1,6 +1,19 @@ | |||
| 1 | import fileinput | 1 | import fileinput |
| 2 | 2 | ||
| 3 | with fileinput.input() as lines: | 3 | with fileinput.input() as lines: |
| 4 | for line in lines: | 4 | rows = [line[:-1] for line in lines] |
| 5 | ... | 5 | pos = [rows[0].find('S')] |
| 6 | 6 | ||
| 7 | s = 0 | ||
| 8 | for row in rows[1:]: | ||
| 9 | newpos = set() | ||
| 10 | for p in pos: | ||
| 11 | if row[p] == '^': | ||
| 12 | s += 1 | ||
| 13 | newpos.add(p-1) | ||
| 14 | newpos.add(p+1) | ||
| 15 | else: | ||
| 16 | newpos.add(p) | ||
| 17 | pos = list(newpos) | ||
| 18 | |||
| 19 | print(s) | ||
