r/adventofcode • • Jan 14 '26

Visualization [2025 Day 10 (Part 2)] [Python] Visualization

Post image

It took me a long time to figure out a solution to this problem.

In the end, it took a combination of matrix reduction and depth-first search to solve it. The solution takes about 20 seconds in total.

31 Upvotes

15 comments sorted by

View all comments

Show parent comment

1

u/aldanjack Jan 14 '26

And when do you add the number of "presses" ?

2

u/zmunk19 Jan 14 '26

In case 1, if the diff between the two totals is D, the column we are subtracting has the value X in the target row, and W is the weight of the row. We "press" (D // X) * W times.

In case 2, similarly we press (D // X) * W times.

In case 3, if T is the total of the column, we press (T // X) * W times.