<Advent of Code 2024 day 20> (no spoilers) :thread...
# advent-of-code
a
Advent of Code 2024 day 20 (no spoilers) 🧵
a
some Part 2 questions: 1. in the given example, is it valid to extend it by 2 more to the right? 2. does the path need to be efficient? like doing a bend (within the quota) even if the bend is not necessary? nvm, the non-bend version would be an overlap anyway
j
You mean go 8 moves to the ending position? Yes, that would be a valid cheat. There is no real limit to a cheat except the 20 picoseconds. I made the mistake initially of thinking that you couldn’t cross an empty space, that you had to stay inside the walls during cheating. But you can pass empty spaces and/or stay on empty spaces for long periods of time
thank you color 1
☝️ 1
a
awesome, thanks! I also wondered about the "stay in the walls during wallhack" but the 2nd example in Part 2 has the path go through the wall on the right and then once more to the right which is actually path (before going into the wall again below it)
why is today's puzzle not called Wall hacking?
n
In the no spoilers thread because I haven’t given up yet but still need to vent. My part 2 solution works on the example down to the sub counts for each picosecond saved, but fails on input. The numbers are waaay too big to even contemplate how I’m going to debug this.
d
The problem with the example is that it's too small to suss out little issues
I had an off by 1 error for 2 hours
Which doesn't matter on the test input, jump 20 vs jump 21 makes no difference
If at any point you want to DM me your strategy I can tell you if I think you have a bug, or if there is an error (non-specific) with the strategy.
I went in to the spoilers channel to determine which was it for myself
Once I hit the 10 minute retry limit
n
Deliberately not reading your replies as I don’t want any hints, which I should have said from the get go. I did see an offer of help which I’m not ready for. In fact, I wrote that vent message before hopping in the shower and now I have a new idea about something I missed. Thanks though!
👍 1
a
> I had an off by 1 error for 2 hours ngl, I had an off-by-2 error. the individual picosec counts off-by-2 wrt the "saved time". I got the totals correct but not the individual counts. ie for the 74 ps example, I had the 76 ps answer. for the 72 ps example I had the 74 ps answer. but for 50 ps, I had the sum of 50 ps and 52 ps answers 🤦
> Deliberately not reading your replies as I don’t want any hints @Neil Banman solved it last night but I haven't read the spoiler thread either. there might be one hint you need (for part 2) which has nothing to do with code. I was very annoyed when I finally realised it. will 🤐 since you said no hints.
n
Sorry, I should have updated to say I figured it out. Won’t spoil anything other than to say I got so caught up in the complicated thing I was doing that I forgot to implement the easy part.
👏 1
a
will leave the hint here for others, because it's not clear from the question: for part 2, the START of the cheat does NOT need to be a WALL 😠 but part 1 clearly says: > Each cheat has a distinct start position (the position where the cheat is activated, just before the first move that is allowed to go through walls) the only change I actually needed was to remove a
filter { it in walls }
. followed by optimisations ignoring neighbours.
n
I don’t read that as a contradiction. Indeed, the cheat cannot start in the wall. You need to go incorporeal first. The diagram is confusing because the start is also the start of the race, ‘S,’ and ‘1’ is not the start of the cheat. So the start of the cheat isn’t notated. But part 2 also says, “Because this cheat has the same start and end positions as the one above, it's the same cheat, even though the path taken during the cheat is different.” It then shows two paths starting from ‘S’ with ‘1’ in different places, so clearly the start is ‘S,’ not ‘1.’ Also, the examples show the cheat floating through regular track as well as walls.
a
the cheat does start in a wall. In all the examples, the "1" (first step of cheat) is a wall. step 0 is on the path itself, and yes, that step-0 is the "from" point, agreed. example from part two has both '1's in the wall. original
Copy code
#.#.#.#.#.###.#
#S#...#.#.#...#
#######.#.#.###
#######.#.#...#
with hack, ex 1:
Copy code
#.#.#.#.#.###.#
#S#...#.#.#...#
#1#####.#.#.###
#2#####.#.#...#
that 1 is in a wall. in ex 2. the '1' is also formerly a wall:
Copy code
#.#.#.#.#.###.#
#S12..#.#.#...#
###3###.#.#.###
###4###.#.#...#
n
Yes, the 1 is in the wall, but that’s not the start. That’s just the elapsed time.
a
ok, but then we are having an off-by-one debate. whether it's "starts" on path or starts on wall, we agree that the next-step from path to cheat has to be a wall, correct? but that's clearly not what the "right" answer has
n
Otherwise, examples 1 and 2 would not be the same cheat because they would then start at different positions (the walls east and south of the ‘S’).
a
both '1's have the same 'S', because that's the true start. agreed. let's move on to talk about that "1". the "1" has to be a wall - based on examples and description. but that isn't the case for part 2.
when I realised "1" does not have to be wall, just to test my theory, I literally changed:
Copy code
point.neighboursUDLR().filter { it in walls }
to
Copy code
point.neighboursUDLR()
and I got the right answer.
and now that I see the spoiler thread, and some other answers I've come across, almost everyone is only checking distance <= 20 and endpoint being on the path. almost no one is checking that the "1" (first point off-the-path) is wall. I wasted hours making sure my first point off-path is in a wall.
n
Got it. Yeah, incorporeal racers can travel anywhere they want. Originally I thought it could only be in walls but I got set straight by example 2.
a
example 2 made it clear that the cheat doesn't need to remain in a wall. but does need "1" to be in a wall. that's untrue for part 2 and contradictory to the description.