5
votes
Day 23: A Long Walk
Today's problem description: https://adventofcode.com/2023/day/23
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>
I woke up at 9pm with the "worst period cramps ever" (quotes because they're always the worst ever). Took painkiller, put on warmer clothing, went back to bed. Overslept the start by an hour but pain was gone and instead I was just high af. I really didn't want to postpone so I called my friend who had already finished, and he helped me through it. Was able to figure out about 60% of it by myself, which in this state I consider a huge win. Fuck biology though.
Python solutions
I finally started treating graph problems like graph problems today! I'm not sure if Haskell has a more idiomatic method of representing a weighted graph (I found
Data.Graph
but that seems limited to directed, unweighted graphs), but I went with a map from each vertex to a sub-map from its neighbors to their corresponding edge weights.I've tried to keep myself from looking anything up beyond language references while solving this year, though I'll admit I was tempted today. I ended up using the same approach for both part 1 and part 2, but reducing the maze down to its junctions and the distances between between them. This got the solving time under 10 seconds, but I'm guessing there's some clever algorithm I'm not thinking of.
So close to the end now!
Haskell Solution