liamcmitchell
A frustrating one for me. I spent a long time trying to understand why some combinations resulted in fewer presses and struggled to keep track of all the layers.
A few things that helped:
- shortest sequences will always use repeated keys e.g.
V<<, never<V< - if a sequence starts and ends on
A, it is independent, cacheable and there is no need to keep track of the keys once summed
Part 1 example (2.1ms): 126384
Part 1 input (0.9ms): 157908
Part 2 example (14.2ms): 154115708116294
Part 2 input (10.8ms): 196910339808654
I passed a cache map every but don’t like it. Is there a nicer way to cache without external deps or using Process? I’ll have a look into macros.
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)
lud
I’m pulling my hair so hard. I can’t reason about this… I spend so many time on that. I just found the correct answer for part 1.
The concept is very fun but it’s also kind of tedious…
Edit: well part 2 is not a surprise hahaha
rvnash
I worked on this for hours and got pretty much no where. I knew exactly what I wanted to do, but I could not clear my head enough to do it. Gave up.
lud
Finally took the time to hack the second part. That was not as simple as “just add cache”
https://github.com/lud/adventofcode/blob/main/lib/solutions/2024/day21.ex
My times are submillisecond haha. (But I parse the 2D maps for digit coordinates at compile time).
@liamcmitchell I used the process dictionary for the memoization. I was not sure it would be faster that carrying a map (and I don’t actually know) but it seems okay.
I have some code duplication because instead of
:<, :<I have{:<, 2}(:<is{:<, 1}), but not for the door digits.adamu
Lol I came here for the answer and you’re all like “too hard
”…
FWIW spent a couple of hours on it, but my code got a length 4 too long for the 4th sample. It’s the first time I failed on the sample in part 1. I suspected it was something to do with the < arrow key being further away, but following my rule of not letting AoC take over my life, I gave up
igorb
This was quite a puzzle. For Part 2, it took me a while to realize that it’s not necessary to return the full sequence and only the length suffices: advent-of-code-2024/lib/advent_of_code2024/day21.ex at main · ibarakaiev/advent-of-code-2024 · GitHub.
lud
Got bitten by that too and had to rewrite everything
bjorng
This took quite a while to figure out and implement correctly, and to make fast enough to handle part 2.
The resulting code is surprisingly fast: the combined runtime for both parts is 0.01 seconds.
https://github.com/bjorng/advent-of-code/blob/main/2024/day21/lib/day21.ex
ken-kost
I implemented your solution and part 2 with real input does not pass for me.
For some reason it’s like the pads and button switch up and I get
** (CaseClauseError) no case clause matching: 60i.e. a directional button goes with numeric pad. Test cases pass. I couldn’t figure out what might be the issue. It fails even if I add only 3 (one more) direct pad or more.My input:
Code:
Maybe you have some ideas what could be the issue?
bjorng
I don’t know how your
Inputmodule is implemented, so I couldn’t run your code without modifications.If run my code with your input, it doesn’t crash.
If I take your code and replace your
parsefunction with myparsefunction, it produces the correct result for my input.So I suspect that something is wrong with either your
parsefunction or yourInputmodule.With your input, my
parsefunction returns the following:ken-kost
Thanks, I’ll try it out. impending update