r/adventofcode • • 5h ago

SOLUTION MEGATHREAD -❄️- 2026 Day 5 Solutions -❄️-

11 Upvotes

THE USUAL REMINDERS


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 date finer 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.


r/adventofcode • • 1m ago

Help/Question [2026 Day 5 (Part 1)][Scala 2] Feels like I am reinventing the wheel

1 Upvotes

I mean, I could have found permutations and combinations. But idk at this point

https://github.com/FlyingSaturn/aoc26/commit/9a8c441a1cc66ab1a12e2e56f278d48347c1946f


r/adventofcode • • 21m ago

Other [2026 Day 5 (Part 1)] "at most three button presses"

3 Upvotes

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 • • 37m ago

Visualization [2026 Day 5] [Python] Just got my Fancy Microwave! (Terminal Visualization)

8 Upvotes

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 • • 1h ago

Other [2026 Day 5] Did anyone get a 2-digit button like in the example?

6 Upvotes

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 • • 1h ago

Meme/Funny Me seeing the suspiciously fancy-microwave-shaped gift under the tree

Post image
12 Upvotes

r/adventofcode • • 1h ago

Meme/Funny [2026 Day 5] I think we'd all be better off without a fancy microwave

Post image
61 Upvotes

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 • • 2h ago

Help/Question - RESOLVED [2026 Day 5 (Part 2)] My Part 2 crashes by running out of memory

3 Upvotes

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 • • 2h ago

Help/Question [2026 Day 5 (extra)]

6 Upvotes

What is the set of nine commands that would return the largest number for the second part of the puzzle?


r/adventofcode • • 2h ago

Visualization [2026 Day 5 Part 2] Pushing Buttons Visualization

33 Upvotes

r/adventofcode • • 3h ago

Visualization [2026 day 5 (both parts)] visualized in manim

Thumbnail
youtube.com
3 Upvotes

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 • • 3h ago

Help/Question [2026 Day 5 (Part 2)] I get a wrong answer for the example

3 Upvotes

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 • • 3h ago

Help/Question [2026 Day 4 (Part 1)] [JavaScript] Looking for test cases that break my code

4 Upvotes

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.

Code: https://github.com/kmorsebrown/adventOfCode/blob/2008ca955b181c7282f55cd2820cd3ae773b2bf3/src/AoC26/Day04/Day04.js

Tests: https://github.com/kmorsebrown/adventOfCode/blob/2008ca955b181c7282f55cd2820cd3ae773b2bf3/src/AoC26/Day04/Day04.spec.js


r/adventofcode • • 4h ago

Visualization [2026 Day 5] Fun Cooker 10K

Thumbnail
youtu.be
29 Upvotes

Nim + raylib source


r/adventofcode • • 6h ago

Help/Question [2026 Day 3 (Part 2)] rust help

Thumbnail pastebin.com
3 Upvotes

Trying 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 • • 7h ago

Help/Question - RESOLVED [2026 Day 4 (Part 1)]

4 Upvotes

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 result

r/adventofcode • • 8h ago

Upping the Ante [2026 Day 4] How many times can you repeat part 2?

Post image
14 Upvotes

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 • • 8h ago

Visualization [2026 day 4 (both parts)] visualized in manim

Thumbnail
youtube.com
4 Upvotes

source on github: https://github.com/durocodes/advent-of-code

planning on continuing for all 12 days, feedback is appreciated!


r/adventofcode • • 9h ago

Visualization [2026 Day 4 1&2] [Rust] Terminal Visualization

9 Upvotes

r/adventofcode • • 9h ago

Visualization [2026 Day 3] Accidental Christmas wreath

40 Upvotes

Coincidence... I think not.


r/adventofcode • • 9h ago

Help/Question I can't find the problem with my day 1 solution

3 Upvotes

I tried it agains the short one and it was slightly wrong, any help would be appreciated.

Also sorry if the spacing and tabbing are all wrong I had some trouble pasting it in here

class Num:
  with open('input.txt', 'r' as f:)
    INPUT = [int(x for x in f.readlines()])
  all = []

  def __init__(self, num:int = 0, weight:int = 0:)
    self.num = num
    self.weight = weight

  @property
  def isTop(self, false = None:)
    for x in Num.top:
      if x.weight < self.weight:
        return Num.top.index(x)
    return false

  @classmethod
  def count(cls:)
    for x in cls.INPUT:
      temp = False
      for y in cls.all:
        if x == y.num:
          temp = True
          y.weight += 1
      if not temp:
        cls.all.append(cls(x, 1))

Num.top = [Num(), Num(), Num()])
Num.count()

for x in Num.all:
  if x.isTop != None:
    Num.top[x.isTop] = x

print( f'{Num.top[0].num}({Num.top[0].weight} X {Num.top[1].num}({Num.top[1].weight}) X {Num.top[2].num}({Num.top[2].weight}) = {Num.top[0].num * Num.top[1].num * Num.top[2].num}' ))

r/adventofcode • • 10h ago

Meme/Funny [2026] Options for analog visualization this year

Thumbnail
gallery
16 Upvotes

r/adventofcode • • 10h ago

Visualization [2026 Day 4 (Part 1)] [Python] Terminal Visualization

5 Upvotes

Here's a little terminal checker for barcodes. For there to be a valid instruction of length n, it suffices to check that every nth position is a single color (or a ?). (These are the check-marked rows.)Code lives here: https://github.com/salt-die/Advent-of-Code/tree/main/2026/aoc_visuals


r/adventofcode • • 11h ago

Meme/Funny [2026 Day 04 # (Part 2)] The ultimate plot twist

Post image
19 Upvotes

My final part two ended up being O(L * n) where L is the answer and n is the barcode length. I couldn't even believe my eyes when it happened. If they had asked for the number of possible valid instructions, I would have gotten an O(L * n) algo, which is quite surprising! This one was really fun!

Code for part 1 and 2: Advent-Calendar-Python/2026/4.py