Skip to content

Commit c7cb303

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

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

2025/day09/solutions.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from itertools import combinations, starmap, compress
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+
9+
rects = [
10+
(min(x1, x2), min(y1, y2), max(x1, x2), max(y1, y2))
11+
for (x1, y1), (x2, y2) in combinations(ns, 2)
12+
]
13+
areas = [(x2 - x1 + 1) * (y2 - y1 + 1) for (x1, y1, x2, y2) in rects]
14+
15+
# Part 1
16+
print(max(areas))
17+
18+
# Part 2
19+
poly = Polygon(ns)
20+
print(max(compress(areas, map(poly.contains, starmap(box, rects)))))

0 commit comments

Comments
 (0)