1
vote
Day 5
Today's problem description: https://adventofcode.com/2026/day/5
Please post your solutions in your own top-level comment. Here's a template you can copy-paste into your comment to format it nicely, with the code collapsed by default inside an expandable section with syntax highlighting (you can replace python with any of the "short names" listed in this page of supported languages):
<details>
<summary>Part 1</summary>
```python
Your code here.
```
</details>
A lot of the work for this one was just parsing, but luckily it wasn't too bad. I took some time to clean my solution up and make it run a bit faster (I originally converted values to and from strings for some operations, which added quite a bit of overhead), and while it could probably still be cleaned up somewhat I'm happy enough with it now. I initially solved Part 1 with three nested loops, but since Part 2 needs BFS anyway both can be solved with a single traversal.
Solution (Lily)
The hardest part of this was just parsing the input into a set of lambdas. Python's lambda capture rules always trip me up. The rest of a straightforward Cartesian product for Part 1 and a BFS for Part 2.
Parts 1 and 2
Visualization