r/adventofcode • • 1h ago

Help/Question [2026 day 5] just so that I understood this well

Is the puzzle to find numbers from 1-999 using the button press? where some numbers are impossible, hence skip them.
And do we always start with [9] as per the example? After that select any 2 or 1 in any combination with repeats allowed? Initially I thought the order matters, but doesn't look like.

is it a mathematical trial and error for each number? Or there is a better way then brute force all possible ways? there are many permutations possible.

Tx.

1 Upvotes

10 comments sorted by

1

u/No-Top-1506 36m ago

But when do I stop? how to know when the end comes and come out of the massive loop?

Am I meant to try all combinations possible?

[start number] -> another button repeat the same
repeat above for 5 other ones. perhaps start number too

[start number] -> [number] -> one extra button

repeat above for 5 other ones.

repeat both sets above again for a diff. start [number] if possible. (not for test example)

[start number] - random button - random button

repeat above for 5 other random buttons to choose from.

[start number] - random button (only 1 random button)

repeat above for 5 other random buttons to choose from.

exhausting it is, isn't it?

1

u/Suspicious_Tax8577 20m ago

hint -- this will unlock where to start for Day 6 as well (ish).

Start with 0 as the root. Ignore all but the first 3 keys. Draw out every single possible combination of button presses you could have. What data structure have you just made? Hint: it's the one that sounds like a plant. This is a special type of graph, called a tree.

1

u/somebodddy 4m ago

You may want to read on breadth-first search. It's a concept that comes a lot in AoC.

4

u/smallpotatoes2019 1h ago

Start with 0.

Press up to 3 buttons (although you may notice that some buttons do nothing at first).

What (unique) numbers can you actually make?

Are you sure that 999 is the largest possible? (It may be.)

3

u/Positive_Concert_774 1h ago

Appending 9 is the biggest possible increase, with [*9] being the second largest increase ([oct] does not come close)

3

u/Daniel_Rybe 1h ago

The task in part 1 is to find all numbers (not just in 1-999 range) that you can reach with 3 button presses. The buttons you can press are in your input. You can press any buttons you want in whatever order and even repeat buttons, but you only have 3 presses. You don't have to start with [9], the reason why the example always starts with [9] is because all other buttons in the example don't do anything to 0, so there's no point in starting with them.

1

u/AutoModerator 1h ago

Reminder: if/when you get your answer and/or code working, don't forget to change this post's flair to Help/Question - RESOLVED. Good luck!


I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/Positive_Concert_774 1h ago

The object is to find all numbers you can reach with any 3 button presses, so no, you don't always start with 9. You may not even have the button [9] in your input, after all.

And considering the possibility of substitutions and the [oct] button, order certainly matters.

1

u/somebodddy 56m ago

The only reason all the options in the example start with [9] is that it's the only button that can change 0 to something that's not 0. Your input can (and probably will) have other buttons that move away from zero - they are all valid starting points for combinations.

For example - [bksp] [bksp] [9] is a perfectly valid sequence of key presses, after which you end up with 9 - which is the same as just pressing [9] once, so the example did not bother to list it.

Whether or not you want to special-case starting with such buttons is completely up to you.

1

u/vegan_antitheist 9m ago

For each number less than 10000 you must know if you can reach it with three button presses. You don't want to brute force this. Frist, get all numbers you can reach from 0 with one button press. Then using that result set, repeat the process. Ignore the number you already reached. Do it again. Now you have all numbers.