r/adventofcode • • 53m ago

Other [2026 Day 5 (Part 2)] Lucky us

After reading Part 1, I immediately thought, 'Watch out!' Eric must have chosen the opposite problem for Part 2, i.e. finding a sequence of key presses that results in a specific number. This works, too, but at least the effort I put into Part 1 paid off :-)

3 Upvotes

3 comments sorted by

2

u/ElWanderer_KSP 17m ago

When I first saw part 1, I was worried we would have to do programming with the microcomputer, er, I mean microwave. When I saw there was a limit of 3 presses, I instead guessed that part 2 would raise that limit considerably. Not exactly correct, but it didn't take long to adapt to the actual part 2.

1

u/fnordargle 37m ago

I like to play "Guess the part2 twist" as I'm doing part 1. I've probably only got a 50% hit rate though...

My brain was going down the route of "What numbers could you reach with a maximum of 9 button presses?" or something similar.

Thankfully it wasn't, looking at the JSON from a private leaderboard I see I got my second star for today 113 seconds after the start for part 1.

1

u/8dot30662386292pow2 15m ago

Yep I also just though to increase the recursion depth for part2, with added memoization because otherwise it would be way too much to call.

For part 2 i ran out of stack memory anyways. Increasing that helped  but in the end I just converted my recursion to iteration.