7
votes
Day 20: Race Condition
Today's problem description: https://adventofcode.com/2024/day/20
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>
Holy off-by-one errors, Batman!
Part 1 (Rust)
Part 2 (Rust)
This runs for almost 3 seconds, I'll need to improve that later.
Came up with the approach I ended up using fairly quickly, but made some silly mistakes along the way. Part 2 still takes ~5 seconds to run, so I'm hoping to see someone else with a better solution.
Smalltalk Solution
Took some time to make this a little faster. My original solution ran BFS individually for every position on the grid - twice - to fill the distance tables, which was incredibly inefficient. I eventually realized I could fill each table with only one traversal, by just allowing BFS to search the whole track. Whereas my original solution took around 6 seconds, my new one runs nearly instantaneously.
Solution (Jai)