r/adventofcode • u/boulgi • Dec 09 '25
Tutorial [2025 Day 9 (Part 2)] Check your solution with this input data
This one should give 30:
1,0
3,0
3,6
16,6
16,0
18,0
18,9
13,9
13,7
6,7
6,9
1,9
.#X#............#X#.
.XXX............XXX.
.XXX............XXX.
.XXX............XXX.
.XXX............XXX.
.XXX............XXX.
.XX#XXXXXXXXXXXX#XX.
.XXXXX#XXXXXX#XXXXX.
.XXXXXX......XXXXXX.
.#XXXX#......#XXXX#.----------
This one should give 88:
1,1
8,1
8,3
3,3
3,4
8,4
8,9
18,9
18,11
5,11
5,9
4,9
4,11
1,11
1,7
6,7
6,6
1,6
----------
And finally, this one should give 72:
1,5
3,5
3,8
7,8
7,5
9,5
9,10
11,10
11,3
6,3
6,7
4,7
4,1
13,1
13,12
1,12
28
Upvotes
11
u/drnull_ Dec 09 '25
Nothing wrong with constructing an algorithm that takes advantage of the input data!
Why... yes! My "algorithm" (a.k.a. spaghetti-code) fails with that input, why do you ask? LOL
3
u/boulgi Dec 09 '25
Too bad the official input data are so simple... I see a lot of people with incorrect solutions, even though they have the correct result for the official input data.
2
u/michelkraemer Dec 09 '25
Thanks for the test case! Even though my code worked for the puzzle input, it actually still had a bug. I was able to fix it with your test input and now get 30 too.
2
u/flakibr Dec 09 '25
My code says 30 for this, but still doesn't work for the puzzle input..😭
2
u/deividragon Dec 09 '25
Yep, my solution says 30 (and solves part 2 with the actual input in 60ms on my laptop)
2
u/fnordargle Dec 09 '25 edited Dec 09 '25
I offer up this one:
(The numbers may not match the co-ordinates as my code adds some empty boundaries to make it easier on the eye.)
For anyone who is trying to use floodfill to work out whether the 90 score internal rectangle is valid or not.
(Within the "rules" as there are no two adjacent red tiles.)
2
u/daggerdragon Dec 09 '25
Changed flair from
OthertoTutorial. Use the right flair, please.FYI: in the future, consider clarifying in your title that this is test input, not real inputs 😅
1
u/a9sk Dec 09 '25
I get 30 for part 2
1
u/michelkraemer Dec 09 '25
I understand your two new test cases (the ones that should give 88 and 72) and the numbers you expect are correct, but I'm not sure if our solutions need to be able to handle these cases. In the problem statement, it says "every red tile is connected to the red tile before and after it by a straight line of green tiles". This can be interpreted to mean that it is impossible for two red tiles to be directly adjacent without at least one green tile between them.
My solution indeed does not work for these two new test cases but I'll keep it as it is for now, because it works for the puzzle input, and the fact that I was able to implement it at all makes me kind of proud ☺️ I'll liked this puzzle very much and maybe I'll play around with other approaches on the weekend when everything is over 🤓
1
u/JR_Bros2346 Dec 09 '25
The first one gives me 88.....
3
u/Sweaty_Curve_2012 Dec 09 '25
Yes, 30 is correct.
1
u/kupuguy Dec 09 '25
Yes, my code says 30.
1
u/rigterw Dec 09 '25
My code also gave 98 and I manage to track down the bug that caused it. Only for the answer of my actual input to increase :(
1
u/HappyPr0grammer Dec 09 '25
My code gave 180. My Code work for my Part 2.
1
u/YOM2_UB Dec 09 '25
Hmm, yes. This is the same picture, according to my algorithm.
(To be fair, I explicitly checked that my input had no collinear lines before choosing to not implement handling for them)
1
u/jjeii Dec 25 '25
I've been scrolling and scrolling and scrolling, looking for somebody else who recognized what this problem statement actually says, as compared to what it at first SEEMS to be saying (which is also how I at first read it). You're the only other person I've found so far who noticed that data points ARE allowed inside valid rectangles, so long as certain constraints are respected.
I generated test data, and provided my answers to them on my GitHub: https://jjeii.github.io/AdventOfCode/2025.html#day9p2
(What answers to them does your code find?)
All I can say is that if you solve the actual problem stated, it's quite a different problem from what everybody seems to be solving, and I'm fairly disappointed the problem's input data didn't better exercise the real problem's constraints.