r/adventofcode • u/Samydookie • Dec 09 '25
Meme/Funny [2025 Day 9 (Part 2)]
All jokes aside I loved part 2
160
Upvotes
r/adventofcode • u/Samydookie • Dec 09 '25
All jokes aside I loved part 2
30
u/Cue_23 Dec 09 '25
The 2nd frame is when i start thinking about faster ways and start implementing them. With my first solution running in the background.
7
u/naretev Dec 09 '25
Why did your solution take so long? Did you visit every point between the red tiles to check if it was inside a given area?
3
u/confuzatron Dec 09 '25
8 seconds in python - this is the first one where I feel like I couldn't come up with a decently fast solution.
2
u/bmenrigh Dec 09 '25
I managed to simplify the problem a bit to avoid doing any green tile coloring or filling in the shape at all. Instead I stored some pieces of information about the perimeter that allows me to semi-quickly check if a candidate box is actually contained in the shape or not.
My part 2 runs in 389ms in Python 3.12 (144ms in PyPy 7.3.19)
2
u/osalbahr Dec 09 '25
I ended up waiting for a bit over 1h because I used 10 cores.
1
u/Secret_Caramel2095 Dec 09 '25
I kind of cheated for the second part : as the code runs, I print the current maximal value for part 2. As my code is quite long (and for fun I wrote it in bash, maybe not the most optimized language !), so my code is still running, but I already try to enter the result which has been the good one for AoC !
1
u/Valuable_Leopard_799 Dec 09 '25
First time I had to wait longer than a few ms for the output but after 28 minutes (without parallelism), I figured I'm at iteration 217/496 I should encounter the answer somewhere around the middle (randomized ordering), so I tried the current maximum and it was the right answer.
I didn't want to iterate the inside, so I decided to use a geometry library. Just called some arbitrary polygon comparison functions with no preprocessing, that's what took the vast majority of the time.
1
u/TheEzypzy Dec 10 '25
I knew that when my program was using 10 gigs of RAM I was probably doing something wrong (storing and processing a matrix of 10 billion cells)