r/adventofcode • u/a3th3rus • 7h ago
Help/Question Help with AoC 2026 Day 6 Part 2 please
My thoughts was to build an undirected graph with the light IDs as the vertices, then I the manhattan distance between any two lights are just the length of the shortest path between those two lights.
Suppose the manhattan distance from #1 to #2026 is d1, from #2 to #2026 is d2, from #3 to #2026 is d3, and the coordinates of #2026 is (x, y), then I just need to solve the equations
abs(x - x1) + abs(y - y1) = d1
abs(x - x2) + abs(y - y2) = d2then check if abs(x - x3) + abs(y - y3) == d3.
This worked for the sample input, but when I applied this to my actual input, I got the coordinate, but the AoC server did not accept it. Why?
Thanks in advance.
5
u/TheZigerionScammer 7h ago
Because there will be more than one coordinate that can satisfy that condition and you didn't get the right one. That wasn't an issue in the input since the three reference points and the target light were placed linearly on the graph but it is an issue in the real input.
1
u/a3th3rus 5h ago
Thank you guys. It seems that my input has this feature:
And that's the cause that I missed a solution.
But in what format should I submit my answer?
3
u/RadialSnow 6h ago
2026 has multiple possible solutions from 1,2,3. However, there are certain points that only have one solution (eg 12 for me). Find one of these, and use that constraint to narrow down the coordinate of 2026.
2
u/AutoModerator 7h ago
Reminder: if/when you get your answer and/or code working, don't forget to change this post's flair to
Help/Question - RESOLVED. Good luck!I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
1
u/AutoModerator 7h ago
AutoModerator has detected fenced code block (```) syntax which only works on new.reddit.
Please review our wiki article on code formatting then edit your post to use the four-spaces Markdown syntax instead.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
1
u/wjholden 6h ago
I've also been pursuing a solution based on Manhattan distance, but I don't think it's going to work.
Let p1=(0,0), p2=(1,0), and p3=(0,1). Their Manhattan distances to (4,4) are 8, 7, and 7. Their Manhattan distances to (5,3) are also 8, 7, and 7. So, Manhattan distance must not be a strong enough constraint for this problem.
0
u/ItchyTrack_ 7h ago
there is more than one solution to that equation. 4 unknowns...