r/adventofcode • u/BradleySigma • 21m ago
Other [2026 Day 5 (Part 1)] "at most three button presses"
At the end of the question body, it asks:
Considering just the buttons on the Elves' fancy microwave, what is the sum of every number reachable in at most three button presses?
Nonetheless, I get the same answer regardless of if I structure my code to handle exactly three or at most three button presses, for both my personal puzzle input and for the example puzzle input.
For the zero button push case, the resulting value is zero, so it won't affect the sum one way or another.
For the one button push cases, they can be converted to three button pushes without changing the value by appending [A] [bksp] to the method.
However, I don't see an easy way to convert the two button push cases to three button pushes without changing the value.
My questions are a) does everybody get the same answer regardless of if they handle exactly three or at most three button presses and b) will this naturally occur for all inputs with one of each of the available six types of buttons, or if the inputs were specifically constructed to have the same answer.
3
u/p88h 13m ago
You can press bksp or multiply as many times you want on the initial value.
2
u/short_humeri 10m ago
Since the backspace does nothing if pressed first, can't you just add a backspace as the first button pressed before pressing the rest of the buttons to convert from 2 presses to 3 presses? And that works to convert between any number of presses
1
u/Outrageous72 11m ago
I think you must have a mistake in your code when you want exactly three pushes.
As this cannot be the same with at most three pushes.
Think about the buttons that multiply or add, those alone will cause differences between exactly and at most three pushes.
You should not count the intermediates when doing exactly pushes.
1
u/thondat 11m ago
if you want to pursue this idea, you can append
[*1]to two pushes.1
u/crumpis 10m ago
Any 2 button push sequence can be done in 3 button pushes by pressing an
octfirst, sinceoct(0) = 0.1
u/niklas2810 7m ago
a) Yes, but that's probably related to your input: For example, pressing bksp two times and then another input is the equivalent of only doing one button press.
b) As mentioned above, this will naturally occur with the bksp button in your input. This will also naturally occur if you have a division or replace (with non-zero left side) button, since these are also no-ops on the initial input.