Skip to content

Commit 6f6f8b1

Browse files
committed
Add solution to 2025-12-09
1 parent efed266 commit 6f6f8b1

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

2025/day09/solutions.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
from itertools import combinations
2+
from shapely import Polygon, box
3+
4+
with open("input") as f:
5+
ls = f.read().strip().split()
6+
7+
ns = [tuple(map(int, line.split(","))) for line in ls]
8+
poly = Polygon(ns)
9+
10+
answer1 = answer2 = 0
11+
12+
for n1, n2 in combinations(ns, 2):
13+
x1, y1 = n1
14+
x2, y2 = n2
15+
rect_size = (abs(x1 - x2) + 1) * (abs(y1 - y2) + 1)
16+
answer1 = max(answer1, rect_size)
17+
18+
rect = box(min(x1, x2), min(y1, y2), max(x1, x2), max(y1, y2))
19+
if poly.contains(rect):
20+
answer2 = max(answer2, rect_size)
21+
22+
# Part 1
23+
print(answer1)
24+
25+
# Part 2
26+
print(answer2)

0 commit comments

Comments
 (0)