liamcmitchell
Advent of Code 2024 - Day 21
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.
Most Liked
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.
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
Last Post!
ken-kost
Popular in Challenges
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #hex









