bjorng
Erlang Core Team
After getting the correct answer for both parts, I spent some time optimizing the execution time. Now the combined time for both parts is 3.4 seconds.
https://github.com/bjorng/advent-of-code/blob/main/2024/day16/lib/day16.ex
Trending in Challenges
Other Trending Topics
Edit: 2026 May 15 - This post is archived.
Mob is alive!!
Main docs: mob v0.7.11 — Documentation
A bit of explanation for the slightly c...
New
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
Hi everyone!
The first release candidate for the Expert language server project is now available!
We’ve published a press release detai...
New
A little off-topic, but I feel like people here have a good head on their shoulders.
I used to be quite good at making software. Was luc...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ai
- #ecto-query
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #metaprogramming
- #hex










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
sevenseacat
For part 1, I used a fairly straightforward priority queue implementation - we’ve had quite a few puzzles like this before.
Part 2 was an interesting one… I ended up implementing some weird “store how we got here” logic as different paths reached the same point and then backtracking over all of those once I found the fastest solution.
I think it might not work correctly if there are two paths to the destination that don’t converge before the destination, but I don’t have that case in any of my inputs so yay!
https://github.com/sevenseacat/advent_of_code/blob/main/lib/y2024/day16.ex
Now I have some boxes from yesterday to go and argue with some more…
antoine-duchenet
It went smoothly, even if this implementation is not very fast
The first part builds a map of the lowest score possible to reach each reachable cell in a given direction, giving the shortest path length for the end cell.
The second part backtracks this map fo flag cells that are part of the shortest path to the end.
lud
I have a solution that takes less than 100ms but I had to rewrite a path finding algorithm that let me pass a function to take the cost in account.
The solution:
https://github.com/lud/adventofcode/blob/main/lib/solutions/2024/day16.ex
The pathfinding code:
https://github.com/lud/adventofcode/blob/main/lib/advent_of_code/path_finder/multi.ex
And as often the grid:
https://github.com/lud/adventofcode/blob/main/lib/advent_of_code/grid.ex
7empest
I used Dijkstra’s shortest path algorithm for this question and implemented this using a min heap. Runtime for both the problems was around 30ms.
My solution for both parts: AdventOfCodeElixir/lib/advent/year2024/day16.ex at main · divxvid/AdventOfCodeElixir · GitHub
Benchee results:
adamu
Rather prescient of me yesterday
But not enough, because my naive initial exhaustive recursive attempt blew up on the actual input and I gave up.
seeplusplus
I’m stumped on this one. My solution for part 1 so far can solve both examples as well as every example listed here:
Any clues?
Grid2Dcode:seeplusplus
I found the issue here was I was trying to memoize the cost of the path from a point,
pand a heading,hbut that cost is dependent on the path taken, so there were cases where the memoized value could be incorrect for some paths.I ended up scratching all of this code and rewriting it with Djikstra’s. Still haven’t solved part 2.
Aetherus
Finally found a solution for Part 2! I just need to twist Dijkstra a bit, so that it continues to find other paths until the total weight exceeds the minimum total weight.
https://github.com/Aetherus/advent-of-code/blob/719c475eeb2cc409cf1c0c9598ce4acbd3389d74/2024/day-16.livemd
ken-kost
I have no desire nor time anymore to slam my head on these harder and harder challenges. Last time I implemented dijkstra was in collage in Java.

First time playing with
I changed some things per my liking but the code is pretty much the same.
I feel I’m not there yet skill wise to solve these challenges efficiently and in satisfactory time. Luckily, I have heads of you fine folks to slam right through.
Again I learned from your code @bjorng. I do vibe with your style.
:gb_setsalso.dimitarvp
I heard people complain that AoC basically monopolizes their free time around the holiday. Yikes. I’ll still give it a go after my dust settles but, not a good sign. Thanks for confirming the impression.