r/adventofcode • • Dec 09 '25

Visualization [2025 Day 9 Part 2] [Python] Visualization of the polygon and best rectangle

Post image

code to generate (and solve): https://gist.github.com/dllu/f8770b967d48d1dfcfc8e2468f7ab97a

I didn't read the problem statement carefully, so my solution works for points in any order. But in fact the problem statement says that they are given in order of appearance along the polygon, so my complex solution is way overkill lol.

65 Upvotes

14 comments sorted by

View all comments

1

u/niahoo Dec 09 '25

Hello,

I'm not sure I understand this code:

for i in range(len(xss) // 2):
    a = [xss[2 * i], y]
    b = [xss[2 * i + 1], y]
    v_segs.append((a, b))

A vertical segment should share the same x coordinate, not the same y coordinate. Is there some inversion on purpose here?

Thank you for the examples! I have the same shape :)

1

u/dllu Dec 09 '25

Yeah I accidentally flipped v and h when naming my variables haha.