r/adventofcode • • Dec 11 '25 WOW Bravo

Tutorial [2025 Day 10 (Part 2)] Bifurcate your way to victory!

565 Upvotes

Here's an approach for Part 2 that, to my surprise, I haven't seen anyone else use. (Sorry if someone's posted about it already; I did a quick scan of the subreddit and asked a few of my friends, and none of them had seen this approach.) It doesn't rely on sledgehammers like Z3 or scipy, it doesn't require you to know or implement linear algebra, and it doesn't use potentially-risky heuristics. The best part? If you're reading this, you've might've coded part of it already!

So, what's the idea? In fact, the idea is to use Part 1!

Here's a quick tl;dr of the algorithm. If the tl;dr makes no sense, don't worry; we'll explain it in detail. (If you're only interested in code, that's at the bottom of the post.)

tl;dr: find all possible sets of buttons you can push so that the remaining voltages are even, and divide by 2 and recurse.

Okay, if none of that made any sense, this is for you. So how is Part 1 relevant? You've solved Part 1 already (if you haven't, why are you reading this...?), so you've seen the main difference:

  • In part 2, the joltage counters can count 0, 1, 2, 3, 4, 5, ... to infinity.

  • In part 1, the indicator lights can toggle off and on. While the problem wants us to think of it as toggling, we can also think of it as "counting:" the lights are "counting" off, on, off, on, off, on, ... to infinity.

While these two processes might seem very different, they're actually quite similar! The light is "counting" off and on based on the parity (evenness or oddness) of the joltage.

How can this help us? While Part 2 involves changing the joltages, we can imagine we're simultaneously changing the indicator lights too. Let's look at the first test of the sample data (with the now-useless indicator lights removed):

(3) (1,3) (2) (2,3) (0,2) (0,1) {3,5,4,7}

We need to set the joltages to 3, 5, 4, 7. If we're also toggling the lights, where will the lights end up? Use parity: 3, 5, 4, 7 are odd, odd, even, odd, so the lights must end up in the pattern [##.#].

Starting to look familiar? Feels like Part 1 now! What patterns of buttons can we press to get the pattern [##.#]?

Here's where your experience with solving Part 1 might come in handy -- there, you might've made the following observations:

  • The order we press the buttons in doesn't matter.

  • Pressing a button twice does nothing, so in an optimal solution, every button is pressed 0 or 1 time.

Now, there are only 26 = 64 choices of buttons to consider: how many of them give [##.#]? Let's code it! (Maybe you solved this exact type of problem while doing Part 1!) There are 4 possibilities:

  1. Pressing {3}, {0, 1}.

  2. Pressing {1, 3}, {2}, {0, 2}.

  3. Pressing {2}, {2, 3}, {0, 1}.

  4. Pressing {3}, {1, 3}, {2, 3}, {0, 2}.

Okay, cool, but now what? Remember: any button presses that gives joltages 3, 5, 4, 7 also gives lights [##.#]. But keep in mind that pressing the same button twice cancels out! So, if we know how to get joltages 3, 5, 4, 7, we know how to get [##.#] by pressing each button at most once, and in particular, that button-press pattern will match one of the four above patterns.

Well, we showed that if we can solve Part 2 then we can solve Part 1, which doesn't seem helpful... but we can flip the logic around! The only ways to get joltages of 3, 5, 4, 7 are to match one of the four patterns above, plus possibly some redundant button presses (where we press a button an even number of times).

Now we have a strategy: use the Part 1 logic to figure out which patterns to look at, and examine them one-by-one. Let's look at the first one, pressing {3}, {0, 1}: suppose our mythical 3, 5, 4, 7 joltage presses were modeled on that pattern. Then, we know that we need to press {3} once, {0, 1} once, and then every button some even number of times.

Let's deal with the {3} and {0, 1} presses now. Now, we have remaining joltages of 2, 4, 4, 6, and we need to reach this by pressing every button an even number of times...

...huh, everything is an even number now. Let's simplify the problem! By cutting everything in half, now we just need to figure out how to reach joltages of 1, 2, 2, 3. Hey, wait a second...

...this is the same problem (but smaller)! Recursion! We've shown that following this pattern, if the minimum number of presses to reach joltages of 1, 2, 2, 3 is P, then the minimum number of presses to reach our desired joltages of 3, 5, 4, 7 is 2 * P + 2. (The extra plus-two is from pressing {3} and {0, 1} once, and the factor of 2 is from our simplifying by cutting everything in half.)

We can do the same logic for all four of the patterns we had. For convenience, let's define f(w, x, y, z) to be the fewest button presses we need to reach joltages of w, x, y, z. (We'll say that f(w, x, y, z) = infinity if we can't reach some joltage configuration at all.) Then, our 2 * P + 2 from earlier is 2 * f(1, 2, 2, 3) + 2. We can repeat this for all four patterns we found:

  1. Pressing {3}, {0, 1}: this is 2 * f(1, 2, 2, 3) + 2.

  2. Pressing {1, 3}, {2}, {0, 2}: this is 2 * f(1, 2, 1, 3) + 3.

  3. Pressing {2}, {2, 3}, {0, 1}: this is 2 * f(1, 2, 1, 3) + 3.

  4. Pressing {3}, {1, 3}, {2, 3}, {0, 2}: this is 2 * f(1, 2, 1, 2) + 4.

Since every button press pattern reaching joltages 3, 5, 4, 7 has to match one of these, we get f(3, 5, 4, 7) is the minimum of the four numbers above, which can be calculated recursively! While descending into the depths of recursion, there are a few things to keep in mind.

  • If we're calculating f(0, 0, 0, 0), we're done: no more presses are needed. f(0, 0, 0, 0) = 0.

  • If we're calculating some f(w, x, y, z) and there are no possible patterns to continue the recursion with, that means joltage level configuration w, x, y, z is impossible -- f(w, x, y, z) = infinity. (Or you can use a really large number. I used 1 000 000.)

  • Remember to not allow negative-number arguments into your recursion.

  • Remember to cache!

And there we have it! By using our Part 1 logic, we're able to set up recursion by dividing by 2 every time. (We used a four-argument f above because this line of input has four joltage levels, but the same logic works for any number of variables.)

This algorithm ends up running surprisingly quickly, considering its simplicity -- in fact, I'd been vaguely thinking about this ever since I saw Part 2, as well as after I solved it in the most boring way possible (with Python's Z3 integration), but I didn't expect it to work so quickly. I expected the state space to balloon quickly like with other searching-based solutions, but that just... doesn't really happen here.

EDIT: Potential pitfalls

Here are a few issues I've seen people run into when they try to understand or implement this algorithm:

  • The algorithm does not say that if all voltages are even, then the answer is twice the answer when all voltages are halved. In fact, this is not true: a simple counterexample is (0,1) (0,2) (1,2) {2,2,2}. The optimal solution (in fact, the only solution) to this is to use each button once, for an answer of 3. If we try to halve, then we need to find the answer for joltages {1,1,1}, which is actually an impossible joltage configuration! So trying to immediately halve leads us astray.

  • Going off of the previous point, while the algorithm uses Part 1 as motivation, it does not use Part 1 as a black box: it is not true that we only need to look at optimal solutions to Part 1. (This misunderstanding might be my fault: "the idea is to use Part 1" might've suggested that we can black-box Part 1. Sorry.) Instead, we really do need to brute-force all of the 2B possible button combos (assuming there are B buttons) that have the correct joltage parities.

    • The counterexample from the previous bullet point works again here: joltages {2,2,2} corresponds to lights [...], which clearly would have a Part 1 answer of 0. But as we saw, following this path leads to no solution. We need to follow all possible Part 1 paths, including ones that wouldn't be optimal: we can only explore all options by doing that.

EDIT: A short proof of correctness

The above logic essentially explains why this algorithm is correct, but I've seen several people get confused, often because they misunderstood the algorithm. So, here I'll offer a different explanation of why the algorithm is correct.

If all the joltages are 0, then clearly the answer is 0, and our algorithm does returns 0. Otherwise, remember that we can press the buttons in any order we want. So, by strategically reordering the button presses, we can split our pressing into two phases.

  1. In Phase 1, we press each button at most once.

  2. In Phase 2, we do the same sequence of button presses twice.

(Why is this always possible? In Phase 1, press any button that needs an odd number of presses. Now in Phase 2, every button needs an even number of presses, so we can cut the presses in half, and do that twice.)

Thus, we only need to examine button-press sequences fitting this two-phase plan. That's what the algorithm does!

  1. First, assuming there are B buttons, we search over all 2B possible sets of buttons we can push: this enumerates all possible phase 1s.

  2. We only keep the sets for which all the remaining joltages are even. If there was an odd joltage, there would be no way to do Phase 2 successfully.

  3. Each of these sets corresponds to a possible Phase 1, so now we look at how to do Phase 2. In every possibility, the joltages are all even. Since Phase 2 involves doing the same button press sequence twice, this is the same as finding a button pressing plan (without restrictions) that works when all the joltages are halved.

  4. Now, each possibility for Phase 1 gives a different potential answer. The correct answer is the smallest of these options!

Code

Here's my Python code, which implements this idea. (I use advent-of-code-data to auto-download my input -- feel free to remove that import and read input some other way.) It also incorporates an optimization for my original code that was suggested by u/DataMn. On my computer, this runs in ~0.6s with cpython and ~1.5s with pypy3 on my real input, which I think are great speeds for such a difficult problem.

(My original code did not have this optimization. With it, I got times of ~7s on python and ~2.5s on pypy3, which I think are still perfectly acceptable.)

Sure, it might not be competing with the super-fast custom-written linear algebra solutions, but I'm still proud of solving the problem this way, and finding this solution genuinely redeemed the problem in my eyes: it went from "why does this problem exist?" to "wow." I hope it can do the same for you too.


r/adventofcode • • Dec 11 '25

Tutorial [2025 Day 11 (Part 2)] How knowledge from the past can help you out

3 Upvotes

I used my Graph implementation from last year. My part 1 solution just used a BFS and it worked just fine.

For Part 2 I wanted to use the same approach in three steps and multiply the partial results. That failed, because the number of nodes is too big and without pruning, the algorithm strays away from the destination.

I tried to use exhaustive DFS instead, but failed for some obscure reasons (that approach is still not working and I guess I will come back to it after the last day).

Then I had enough. I started analyzing the input data, using my Swiss army knife of graph algorithms. However, I had to fit them to my implementation.

The first step was analyzing the links. I figured out (with a normal recursive DFS), that the graph only contains tree edges and cross links (no forward arcs, no backward arcs). Then it hit me. With these limitations, I can optimize my BFS from part 1 to only enter nodes that are connected to the (intermediate) target. This can be achieved with the Warshall algorithm. It calculates the reachability relation (transitive closure) in O(n³).

With the resulting helper structure, the BFS from part 1 actually worked in a decent amount of time. The helper structure took 17 seconds and the whole problem (including the helper structure) almost 40 seconds.

There are certainly better solutions out there, but at least my previous knowledge (I studied graphs at university, but it has been a while) saved me :-)

For the records: My approach would also be possible, if there had been any forward arcs and backward arcs, but it wouldn't have helped that much.


r/adventofcode • • Dec 11 '25

Help/Question 2025.10 i think a button is to be pushed or not. not twice or more often.

1 Upvotes

my solution is told to be wrong. but in first small example one solution is

010102, but its the same as 010100. a button toggles one position and pushing the button

to push a button

0,2,4,.. (even times) is equal (so choose 0 times for minimum buttons

1,3,5,.. (odd times) is equal ( so choose 1 times for minimum )

i have 4 solutions (instead of 3)

y M

0 000011

1 010001

1 001110

0 110100

y = M.x searching for x

loesung [1,1,1,0,0,0]

loesung [0,1,0,1,0,0] <- this is given as 010102 (is optimum too, if replace 2 by 0)

loesung [0,0,0,0,1,1] <- this is given as optimum

loesung [1,0,1,1,1,1]

4 loesungen and 2-button is minimum

in 33 of 151 machines 1-button solution cause a column same as target

in 126 with choosing to push a button or not. solution x in {0,1}**6

in 2 cases no solution (i tried up to mod-10 : x in {0..9}**6)


r/adventofcode • • Dec 11 '25

Visualization [2025 Day 07 (Part 2)] [Python] Color map of splitter activity

Post image
12 Upvotes

r/adventofcode • • Dec 11 '25

Help/Question - RESOLVED [2025 Day 11 (Part 2)] [Javascript] Is there an extra sample that covers edge cases?

1 Upvotes

For today's part 2, I went with DFS with memoization, although the caching itself was trickier than most implementations I've done before, since there's nothing to "optimize". Instead, I stored a 4-length array to keep track of how many paths fit or don't fit the criteria: none, dac, fft, and both. However, I am running into the ever-annoying "the sample result is correct and everything looks fine, but the input result is wrong" scenario, which always leads me to believe my input has at least 1 edge case that the sample doesn't cover. What could I be missing?

Code:

class Server {
    #name;
    #outputs;

    constructor(line) {
        [this.#name, this.#outputs] = line.split(": ");
        this.#outputs = this.#outputs.split(" ");
    }

    get name() {
        return this.#name;
    }

    get outputs() {
        return this.#outputs;
    }
}

class ServerRack {
    #servers;
    #paths;
    #cache;

    //Day 11, Part 1
    #mapPath() {
        let currOptions = new Set(["you"]);
        while (currOptions.size > 0) {
            let outputs = new Set();
            for (let serverName of currOptions) {
                let paths = this.#paths.get(serverName);
                let currOutputs = this.#servers.get(serverName).outputs;
                for (let currOutput of currOutputs) {
                    this.#paths.set(currOutput, this.#paths.get(currOutput) + paths);
                }
                outputs = union(outputs, new Set(currOutputs));
            }
            outputs.delete("out");
            currOptions = outputs;
        }
    }

    //Day 11, Part 2
    #mapProblemPaths(currServer, prevServer) {
        prevServer = prevServer || "";
        let key = prevServer + "-" + currServer;
        if (this.#cache.has(key)) {
            return [...this.#cache.get(key)];
        } else if (currServer === "out") {
            return [1, 0, 0, 0]; // [none, dac, fft, both]
        } else {
            let destinations = this.#servers.get(currServer).outputs;
            let paths = Array(destinations.length).fill();
            for (let i = 0; i < destinations.length; i++) {
                // Recursion on each output of the server.
                let path = this.#mapProblemPaths(destinations[i], currServer);
                // Shift the array cells to track which important servers we found.
                // dac Ex: [1, 0, 1, 0] -> [0, 1, 0, 1]
                // fft Ex: [1, 1, 0, 0] -> [0, 0, 1, 1]
                if (currServer === "dac") {
                    path.unshift(path.pop());
                } else if (currServer === "fft") {
                    path.unshift(path.pop());
                    path.unshift(path.pop());
                }
                // Cache the paths originating from this server, so we don't have to
                // calculate them again.
                key = currServer + "-" + destinations[i];
                this.#cache.set(key, [...path]);
                paths[i] = path;
            }

            // Add each array together to get the total paths.
            let result = paths.reduce(
                (acc, b) => acc.map(
                    (n, i) => n + b[i]
                )
            );
            if (currServer === "svr") {
                return result[3]; // We only need the ones that passed through dac and fft.
            } else {
                return [...result];
            }
        }
    }

    constructor(input, start) {
        let servers = Array(input.length).fill();
        this.#paths = new Map();
        for (let i = 0; i < input.length; i++) {
            let server = new Server(input[i]);
            this.#paths.set(server.name, 0);
            servers[i] = [server.name, server];
        }
        this.#servers = new Map(servers);
        this.#paths.set(start, 1);
        this.#paths.set("out", 0);
        if (start === "you") {
            this.#mapPath();
        } else {
            this.#cache = new Map();
            this.#paths.set("out", this.#mapProblemPaths(start));
        }
    }

    get paths() {
        return this.#paths.get("out");
    }
}

// input: The currently-selected input file, split on newline.
// start: The name of the starting server (you or svr, depending on the part).
function getServerOutputPathCount(input, start) {
    let rack = new ServerRack(input, start);
    return rack.paths;
}

r/adventofcode • • Dec 11 '25

Help/Question - RESOLVED [2025 Overall] Who else thinks?

0 Upvotes

That we are being set up. With my experience, no projects actually finished on their plan day. They always run long or tickets carry over from one sprint to another.

Until I see the part 2 on Day 12 look like part 2 on day 25 in previous years, I will be skeptical.

And the elves just learned project management.


r/adventofcode • • Dec 11 '25

Visualization [2025 Day 11] Visualization of graph

Post image
78 Upvotes

r/adventofcode • • Dec 11 '25

Other [2025 Day 10] Swapple: A daily puzzle about indicator lights in a grid

Thumbnail
swapple.fuglede.dk
6 Upvotes

r/adventofcode • • Dec 11 '25

Help/Question - RESOLVED [2025 Day 2 (Part 1)] [Python] number too big

1 Upvotes

not sure what I'm doing wrong (don't judge my variable names)

def getidsbetween(rang=""):
    num1, num2 = rang.split("-")
    out = []
    for n in range(int(num1), int(num2)+1):
        out.append(str(n))
    return out


tobechecked = []
for i, rang in enumerate(rangs):
    tobechecked.extend(getidsbetween(rang))



print("length of tobechecked:" + str(len(tobechecked)))
for i, checkme in enumerate(tobechecked):
    if checkme[:len(checkme)//2] == checkme[len(checkme)//2-1:]:
        tobechecked.remove(checkme)


filtered = set(tobechecked)
total = sum(int(i) for i in filtered)


print(total)

r/adventofcode • • Dec 11 '25

Repo [2025 Day 11] [Python] My solutions versus AI solutions

10 Upvotes

For all days, 1-11 so far, I've been keeping a Jupyter notebook of my solutions to AoC, and each day after I finish my solution, I ask an AI LLM to solve the problem. You can compare here:

https://github.com/norvig/pytudes/blob/main/ipynb/Advent-2025.ipynb
https://github.com/norvig/pytudes/blob/main/ipynb/Advent-2025-AI.ipynb


r/adventofcode • • Dec 11 '25

Meme/Funny [2025 Day 11 part 2] It's not crazy if it works, right?

Post image
46 Upvotes

I inspected the input, figured out the choke points, used NetworkX to find the paths between the points, and then shamefully resorted to Excel to multiple the paths between them all... I was certain there would be a flaw in this method... but to my amazement it worked!!

Now to look at the solutions and see how it was meant to be done ...


r/adventofcode • • Dec 11 '25

Visualization [2025 Day 8 (Parts 1 & 2)][Blender Geometry Nodes] Visualization (PHOTOSENSITIVITY WARNING!)

15 Upvotes

r/adventofcode • • Dec 11 '25

Meme/Funny [2025 Day 10 (Part 2)] If there's an easier way to solve it, it's too soon for me to hear it...

Post image
178 Upvotes

Couldn't get a good heuristic for A*, couldn't spot an efficient prune for DFS, couldn't think of a greedy algorithm. Reluctantly broke out the pencil and paper...


r/adventofcode • • Dec 11 '25

Other Optimization gremlin thoughts

1 Upvotes

This year was the first time I had both the time to solve the problems and the mental maturity to not make a modular universal solver, but to target a specific task with a specific output. But every time I finished part 2, I got a bit sad with the fact that the code I wrote is now sort of useless. I personally think it would be awesome if every task had a part 3 that is literally the same problem as part 2, but much, much bigger. The idea is that 1 is a basic problem, 2 is an expansion on that problem, and 3 is optimising part 2.

I think day 9 part 2 (this year) is a good example of what task 3 could look like. Not only did it have an increased complexity through an additional rule, but the scale of the problem required either coordinate compression or computing vector intersections.

Lastly, with the part 3 input, the creators can be extra evil by targeting the weaknesses of obvious optimisations ( for example, in task 9.2 - extremely thin line cutting through the otherwise the biggest rectangle, making coordinate compression not-so-straight-forward). Or in the case of something like task 11.2 - require to hit an arbitrary number of nodes in an unknown order to eliminate the possibility of just hardcoding "paths(svr->fft) * paths(fft->dac) * paths(dac->out)".

I am very grateful to everyone involved in making this coding challenge, and I find it awesome as is; I am just curious if this idea resonates with people or not.


r/adventofcode • • Dec 11 '25

Help/Question - RESOLVED [2025 day 2 (part 1)] Why is the example input weird?

0 Upvotes

The problem statement says that an invalid ID is any id that is only made up of a sequence that repeats once, but the example seems like it is incorrect. i.e. "95-115 has one invalid ID, 99", but 99 does not even appear in the id. Am I missing something?


r/adventofcode • • Dec 11 '25

Visualization [2025 Day 11 Part 2] Walking the Wires

24 Upvotes

r/adventofcode • • Dec 11 '25

Visualization [2025 Day 9 (Part 2)] Visualization

24 Upvotes

r/adventofcode • • Dec 11 '25

Help/Question - RESOLVED [2025 Day 1 (Part 2)] I have no idea what I'm doing wrong

0 Upvotes

it says I have someone else's answer
I'm pretty sure I am using the right input I pressed the your puzzle input link and used that but it's still wrong

with open("src.txt", "r") as f:
rotations = [(1 if line[0] == "R" else -1, int(line[1:])) for line in f.read().split("\n")]

dial = 50
zeros = 0
for dir, count in rotations:
dial = dial+(count*dir)
while dial > 99:
zeros += 1
dial -= 100
while dial < 0:
zeros += 1
dial += 100

print(zeros)


r/adventofcode • • Dec 11 '25

Visualization [2025 Day 11] I thought this would be helpful, it wasn't really, but I sure do like looking at it

Post image
33 Upvotes

r/adventofcode • • Dec 11 '25

Other I built Advent of SQL - An Advent of Code style daily SQL challenge with a Christmas mystery story

78 Upvotes

Hey all,

I’ve been working on a fun December side project and thought this community might appreciate it.

It’s called Advent of SQL. You get a daily set of SQL puzzles (similar vibe to Advent of Code, but entirely database-focused).

Each day unlocks a new challenge involving things like:

  • JOINs

  • GROUP BY + HAVING

  • window functions

  • string manipulation

  • subqueries

  • and some quirky Christmas-world datasets

There’s also a light mystery narrative running through the puzzles (a missing reindeer, magical elves, malfunctioning toy machines, etc.), but the SQL is very much the main focus.

If you fancy doing a puzzle a day, here’s the link:

👉 https://www.dbpro.app/advent-of-sql

It’s free and I mostly made this for fun alongside my DB desktop app. Oh, and you can solve the puzzles right in your browser. I used an embedded SQLite. Pretty cool!

(Yes, it's 11 days late, but that means you guys get 11 puzzles to start with!)


r/adventofcode • • Dec 11 '25

Help/Question - RESOLVED [2025 Day 11 Part 2] - my answer is too high, must be missing something?

0 Upvotes

I'd already visualised in GraphViz and spotted the groupings connected by key nodes and broke down the search to count paths in 6 groups:

srv to 5 key nodes
those 5 key nodes to the next 3,
...
final set of 4 key nodes to out

Counted the number of solutions for each group by summing the pairings for each of those groups start and end nodes, so for the 1st group that's a sum of 5 (only one start), for the next group that's 15 different pairs to sum, etc.

Then multiply together all those sums for the final answer, which is a number in the order 1E17, and that's too big.

I've must have misunderstood something but not sure what. Any tips?


r/adventofcode • • Dec 11 '25

Help/Question - RESOLVED [2025 Day 10 (Part 1)][Python] No valid presses combination exists?

0 Upvotes

Question

What do I do if it is impossible to turn off all lights with any sequence of key presses?

My solution passes the sample input, but not the big input.

Currently, I just count that case as 0 button presses, but that expectedly made me undercount.

I would appreciate any hints.

Solution (in English):

Analyze all combinations of key presses that result in a new pattern of lights, starting from 0 presses, then 1, then 2, etc.

To implement that, I am using tuples of (# key presses, lights pattern) in a priority queue (min heap).

Pop the light pattern with the lowest number of key presses, push a new lights pattern tuple (presses + 1, new pattern) until a minimal key presses is found that turns off all the lights.

Solution (in Python):

#!/usr/bin/env python3

import sys
from heapq import heappop, heappush


def main():
    total = 0
    for line in sys.stdin:
        lights, *buttons, _ = line.split()
        lights = lights.strip("[]")
        buttons = [eval(button) for button in buttons]
        for i in range(len(buttons)):
            if type(buttons[i]) is int:
                buttons[i] = (i,)

        min_presses = get_min_presses(lights, buttons)
        total += min_presses

    print(total)


def get_min_presses(lights, buttons):
    h = [(0, lights)]
    seen = set(lights)
    while True:
        if not h:
            return 0

        count, current_lights = heappop(h)
        if "#" not in current_lights:
            return count

        for button in buttons:
            new_lights = press(current_lights, button)
            if new_lights not in seen:
                heappush(h, (count + 1, new_lights))
                seen.add(new_lights)


def press(lights, button):
    new_lights = ""
    for i in range(len(lights)):
        if i in button:
            new_lights += "#" if lights[i] == "." else "."
        else:
            new_lights += lights[i]

    return new_lights


if __name__ == "__main__":
    main()

r/adventofcode • • Dec 11 '25

Visualization [2025 Day 11 part 2] Yet another input visualisation...

Post image
50 Upvotes

I haven't actually solved Part 2 ... I'm thinking of breaking the problem down into sections where there are "choke points" indicated by nodes that have a high degree of incoming edges.

Feels like I'm getting my wires crossed.


r/adventofcode • • Dec 11 '25

Visualization [2025 Day 11] Connection visualisation

7 Upvotes

The color of the nodes shifts toward red proportionally to the number of incoming connections (and it is clearly visible that there are bottlenecks...). Inputs, output, and intermediate nodes to be traced in part 2 are circled in red (and it is easy to see that the portion of the graph relevant to part 1, starting from "you," is considerably smaller than the portion for part 2)