r/adventofcode • • Dec 03 '25

Visualization [2025 Day 03 (Part 2)]

The sliding window visualisation.

  • init window: from 0 to the right side minus 11 items
  • find max there
  • move window one step right
  • cut left side to the chosen max battery
  • find max there...
17 Upvotes

8 comments sorted by

1

u/AbjectOven3670 Dec 13 '25

This looks great at first sight, but it also gets me to wonder if I got another issue then everyone else :joy:

Following your steps above, would be broken with the following number: 818181911112111

As your steps would take number 9 as highest (in the first set of 12) and then move the cursor there. And then you only have 9 more numbers (including 9), with other words 911112111 .

Maybe I am missunderstanding the steps above, but I just cant get it to work in my head. Am I missunderstanding something maybe?

1

u/EverybodyCodes Dec 13 '25
  • init window: from 0 to the right side minus 11 items

so in the first step your window looks like this: 8181, and you pick the first 8 from the left

→ More replies (1)

3

u/Cojonez69 Dec 03 '25

You are a legend, Thank you!

2

u/EmmiPigen Dec 03 '25

Thanks so much, it helped me figure out how to do this. Also great visualisation

2

u/ohhaiitsdave Dec 03 '25

Love the visualisation and the description set me on the right path for solving this (after multiple wrong ones) so thanks!

2

u/daggerdragon Dec 03 '25

Fancy fonts make everything better :3

1

u/kwiat1990 Dec 04 '25

Thanks to your visualization and after writing the entire process step by step down by hand, the solution was not only simple to implement but also faster than the one for part 1. The only thing I struggled a bit was the fact that the condition to break the while loop should be `>= 0` a not `> 0`.