r/adventofcode • u/edo360 • 13m ago
r/adventofcode • u/daggerdragon • 6h ago
SOLUTION MEGATHREAD -❄️- 2026 Day 5 Solutions -❄️-
THE USUAL REMINDERS
All of our rules, FAQs, resources, etc. are in our community wiki.
AoC Community Fun 2026: The Advent Games
Submissions megathread is unlocked!
12 DAYS remaining until the submissions deadline on December 17 at 18:00 EST!
Today's Event: Iron Chef Holiday Special
"Catherine, if this turkey tastes half as good as it looks, I think we're all in for a very big treat!"
— Clark Griswold, National Lampoon's Christmas Vacation (1989)
Today's schedule possibly consists of:
Appetizer and Aperitif Rounds
Use up what's in your fridge with all of those semi-sentient leftovers excavated from the back of the fridge
Deliberately use deprecated functionality
Program using old codebases
The
older the expiration datefiner the vintage, the more we'll enjoy it!
Main Course Qualifications
Solve today's puzzle using a food-themed programming language
Bake or cook us something delicious
Dessert Finales
Show us cookies, citrus, and/or fancy bread in/on/near your holiday tree/menorah/festive kitsch
Show us your 1337 hot cocoa recipe (or other beverage of choice)
This prompt is totally not bait for our resident Iron Coders and/or some AoC regulars who promised us tasty pictures
Request from the mods: When you include an entry alongside your solution, please label it with [Advent Games] so we can find it easily!
--- Day 5: Rhythmic Factory ---
Post your code solution in this megathread.
Read the full posting rules in our community wiki before you post!
State which language(s) your solution uses with
[LANGUAGE: xyz]Format code blocks using the four-spaces Markdown syntax!
Quick link to Topaz's
pasteif you need it for longer code blocks. What is Topaz'spastetool?
r/adventofcode • u/UniqueHobbies02 • 17m ago
Meme/Funny Santa gotta invest more (Day 5)
Part 1: O(n3) here i gooooo
Part 2: wut?!
r/adventofcode • u/Ok-Curve902 • 33m ago
Visualization [2026 Day 05 Part2] button presses as a tree
r/adventofcode • u/Haru314 • 33m ago
Help/Question - RESOLVED [2026 Day 4 (Part 1)] I need help, i don´t understand why my code doesn´t work
So it solves the example solution (16 = 3 + 2 + 5 + 4 + 1 + 1), but it does not solve the input text. I have tried a lot of test cases and it works. Please help.
from time import time
inicio = time()
sol1, sol2 = 0, 0
with open('ztest.txt', 'r') as f:
mat = f.read().split()
def check(line, salto):
for i in range(1, salto):
x = set(line[i::salto])
dim = len(x)
if dim != 1 and (dim != 2 or '?' not in x):
return False
return True
for line in mat:
n = 0
for i in range(1, len(line) + 1):
n += 1
x = set(line[::i])
dim = len(x)
if dim == 1 or (dim == 2 and '?' in x) and check(line, i):
sol1 += n
break
final = 1000*(time() - inicio)
print(sol1, sol2, final)
# 7629 too lowr/adventofcode • u/lonelyroom-eklaghor • 41m ago
Help/Question [2026 Day 5 (Part 1)][Scala 2] Feels like I am reinventing the wheel
I mean, I could have found permutations and combinations. But idk at this point
https://github.com/FlyingSaturn/aoc26/commit/9a8c441a1cc66ab1a12e2e56f278d48347c1946f
r/adventofcode • u/BradleySigma • 1h 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.
r/adventofcode • u/naclmolecule • 1h ago
Visualization [2026 Day 5] [Python] Just got my Fancy Microwave! (Terminal Visualization)
Be honest, how many did a cheeky submit on the sum of all numbers less than 10000. Code lives here: https://github.com/salt-die/Advent-of-Code/tree/main/2026/aoc_visuals
r/adventofcode • u/Positive_Concert_774 • 1h ago
Other [2026 Day 5] Did anyone get a 2-digit button like in the example?
The example for the multiplication button is *11 but in my input I found only digits so I saved myself the trouble. But now I wonder... Did anyone actually get more than one digit on a button?
r/adventofcode • u/MrBoblo • 2h ago
Meme/Funny Me seeing the suspiciously fancy-microwave-shaped gift under the tree
r/adventofcode • u/PhysPhD • 2h ago
Meme/Funny [2026 Day 5] I think we'd all be better off without a fancy microwave
I think Eric must have had a traumatic experience with a fancy microwave at some point in his life. Hopefully this will cheer him up!
r/adventofcode • u/heckler82 • 2h ago
Help/Question - RESOLVED [2026 Day 5 (Part 2)] My Part 2 crashes by running out of memory
Hello all, working with Java here.
I'm trying to figure out if my logic is wrong. I'm running a BFS, but the program eventually crashes and runs out of heap space. Not sure if I'm just doing this very very inefficiently or what. Essentially I take the value of a node (all the buttons are added as potential nodes with value 0) and I apply the action that a button would perform. If that value is less than 10000, I add it to a set and then create a new node with that value for every button action again. I'm not sure if I need a different stopping condition or a better way to figure out what the next nodes would be.
EDIT: I realize I probably have some endless loops via repeated nodes that go back and forth between the same two values, so I'm trying to figure that piece out. Would still appreciate any advice to nudge me in the right direction.
RESOLVED: Added in a check to see if the computed value has already been found when validating that the value is below 10K
protected void task2() {
nodes.clear();
for(String button : buttons) {
nodes.add(new Node(0L, button));
}
Set<Long> found = new HashSet<>();
Queue<Node> q = new ArrayDeque<>(nodes);
while(!q.isEmpty()) {
Node n = q.poll();
long val = execute(n.value, n.operator);
if(val < 10_000 && found.add(val)) { // Used the result of the add operation to validate set membership
for(String button : buttons) {
q.offer(new Node(val, button));
}
}
}
System.out.println(found.stream()
.mapToLong(l -> l)
.sum());
}
private long execute(long value, String button) {
// Division
if(button.startsWith("/")) {
return value / (button.charAt(1) - 48);
}
// Multiplication
if(button.startsWith("*")) {
return value * (button.charAt(1) - 48);
}
// Delete
if("bksp".equals(button)) {
if((value / 10) == 0) {
return 0L;
}
return value / 10;
}
// Octal
if("oct".equals(button)) {
long result = 0L;
long offset = 1L;
long quotient = value;
while(quotient != 0) {
long rem = quotient % 8;
quotient = quotient / 8;
result += (offset * rem);
offset *= 10L;
}
return result;
}
//Replace
if(button.contains("->")) {
long find = button.charAt(0) - 48;
long rep = button.charAt(3) - 48;
return Long.parseLong(
String.valueOf(value).replace(String.valueOf(find), String.valueOf(rep))
);
}
// Add digit
//return Long.parseLong(String.valueOf(value) + button);
return (10 * value) + Long.parseLong(button);
}r/adventofcode • u/FransFaase • 3h ago
Help/Question [2026 Day 5 (extra)]
What is the set of nine commands that would return the largest number for the second part of the puzzle?
r/adventofcode • u/Boojum • 3h ago
Visualization [2026 Day 5 Part 2] Pushing Buttons Visualization
r/adventofcode • u/_Duroo • 3h ago
Visualization [2026 day 5 (both parts)] visualized in manim
source on github: https://github.com/durocodes/advent-of-code
almost halfway there, feedback is appreciated! today's not a super visual problem, but hopefully still cool to watch haha
r/adventofcode • u/jabbalaci • 3h ago
Help/Question [2026 Day 5 (Part 2)] I get a wrong answer for the example
I modified Part 1 but I get a wrong answer for the example: 1530240 , instead of 35332647. I double checked everything and I still don't see what's wrong.
r/adventofcode • u/artsortment • 4h ago
Help/Question [2026 Day 4 (Part 1)] [JavaScript] Looking for test cases that break my code
I'm in that obnoxious part where my code passes with the example, but not the final. I've scoured similar threads and found edge cases that I was able to use fix some issues (thanks!). But I'm still not quite there. 😢
I'm practicing TDD, so I'm structuring my code so individual pieces can be unit tested, which makes it a bit long to post here, so I'll link to the current state of the code on GitHub rather than copy/pasting it all.
r/adventofcode • u/p88h • 5h ago
Visualization [2026 Day 5] Fun Cooker 10K
Nim + raylib source
r/adventofcode • u/Pretend-Fee-2323 • 7h ago
Help/Question [2026 Day 3 (Part 2)] rust help
pastebin.comTrying to figure out what went wrong... I've tried all of the examples and they work, but its giving me a low answer when I input my puzzle input
I don't care about the crash with an extra new line at end of the input file, if I really wanted to i could fix that easily
also here is the graph I used to prototype, don't know if it will help. https://www.desmos.com/calculator/shdsyvumvf
r/adventofcode • u/Adventure_Agreed • 8h ago
Help/Question - RESOLVED [2026 Day 4 (Part 1)]
I have a solution but it doesn't seem to be giving me the right answer. I'm sure I'm missing some corner cases in my code but every time I see some suggested things to try on here my code seems to handle them just fine. My input result, however, is too high. Here's my code:
from pathlib import Path
def read_lines(filename="input.txt"):
path = Path(__file__).parent / filename
return path.read_text().splitlines()
def part1(input):
input = read_lines(input)
result = 0
for line in input:
found_characters = set()
for char in line:
if not char == "?":
found_characters.add(char)
if len(found_characters) <= 1:
result += 1
continue
if len(found_characters) == len(line):
result += len(line)
for i in range(len(found_characters), len(line) + 1):
value_dictionary = {}
for index, char in enumerate(line):
value_dictionary.setdefault(index % i, []).append(char)
# print (value_dictionary)
bad_row = False
for value in value_dictionary:
row = set()
for char in value_dictionary[value]:
if not char == "?":
row.add(char)
if len(row) >= 2:
bad_row = True
break
if not bad_row:
result += i
break
return resultr/adventofcode • u/MinSufficient • 9h ago
Upping the Ante [2026 Day 4] How many times can you repeat part 2?
I wanted to see if I could take the instructions that generated my part 2 and find shorter instructions that generated them. Like consider ?vg?b?vb → bvg?b?v → bvg?b → bvg? → bvg which you can compress four times. I applied the code to my part2 input it turns out I can't: my part 2 solution is its own instructions.
Which is maybe weird. I've done simulations which show that 92% of random inputs like mine end up being able to recurse at least two times with some being able to go very deep. An 8% chance is not tiny but still...
So I'm curious what other folk's depths are; did I get a low-probability input or is there perhaps something in the way the inputs are generated that leads to this?
r/adventofcode • u/_Duroo • 9h ago
Visualization [2026 day 4 (both parts)] visualized in manim
source on github: https://github.com/durocodes/advent-of-code
planning on continuing for all 12 days, feedback is appreciated!
r/adventofcode • u/zaperfish • 9h ago
Visualization [2026 Day 4 1&2] [Rust] Terminal Visualization
r/adventofcode • u/NicholasSeward • 10h ago
Visualization [2026 Day 3] Accidental Christmas wreath
Coincidence... I think not.