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
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself.
My main conc...
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
- #ecto-query
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










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.