<Advent of Code 2024 day 21> (no spoilers) :thread...
# advent-of-code
a
Advent of Code 2024 day 21 (no spoilers) 🧵
n
Not going to have time to work on this tonight and maybe not till after Christmas, but I loved reading the problem! Classic AoC humor and intriguing considerations.
m
My code is working on the 4 example inputs but not the 5th one...
k
Mine works on all example input but wrong for my puzzle 🤔
d
I’m pretty sure I know where to go here but I can already tell this is going to be long, so I also may need to postpone to the more relaxed time around New Year’s
b
an hour+ debugging to get it right on the example input, and its wrong on my input 😢
d
TBH probably better for the whole family if I pick these last 5 days back up on 12/28 — lots to do
j
at least I got part 1 to work, for part 2 I'm still thinking about
m
I just got part 1 to work, but my solution is not going to cut it for part 2 😄
k
p1 working as well. But my solution is so bad, there's no way it works for p2
h
@Marcin Wisniowski any hint as to a likely issue? I have exactly the same problem... my solution works for samples 1-4, but fails on example 5 (379A)... I end up with 72 steps, instead of 64??!?
I get the feeling that my "all the X steps, then all the Y steps" (or vice versa as necessary to avoid the empty key pad spaces) strategy may not result in the "shortest" number of steps for the next robot up the chain in some edge cases? Hence the repeated references in the puzzle description to "shortest sequence of button presses"
m
@HCP There are multiple ways to reach a button (left, up vs up, left), and choosing one over the other might make less moves necessary for the keypad one level higher.
Taking this into account is what solved my issue.
h
ooooo I think I see the optimisation in the "path".
m
I now have a different solution that is fast enough to solve part 2, but it's giving a wrong answer... it's still correct for part 1.
h
Hmmmm, so it seems I had set my initial grid of the keypad up wrong, specifically the X co-ordinate for "3", and because that only appeared in example 5, that was the only place the error showed up. Unfortunately, while my solution works for the examples... it doesn't work for the input 😞
j
Oh that was soooooo brutal puzzle. I mean, the whole time I was doing part 1 I was thinking to myself: please let part 2 not be what I'm thinking it's going to be. Please let part 2 not be what I'm thinking it's going to be". And what was part 2? Of course what I predicted 😆
j
I'm still trying to figure out why in the example with the explaination for part 1 from the second row
Copy code
v<<A>>^A
is choosen for <A and in the first row a <A is replaced by <v<A>>^A instead. That is of cause only relevant for part 2, since part 1 I was able to solve.