aboutsummaryrefslogtreecommitdiff
path: root/2025/09/puzzle-1.py
diff options
context:
space:
mode:
Diffstat (limited to '2025/09/puzzle-1.py')
-rwxr-xr-x2025/09/puzzle-1.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/2025/09/puzzle-1.py b/2025/09/puzzle-1.py
new file mode 100755
index 0000000..6d42141
--- /dev/null
+++ b/2025/09/puzzle-1.py
@@ -0,0 +1,29 @@
+#!/usr/bin/python3
+
+import itertools
+
+
+type Point = tuple[int, int]
+
+
+def main() -> None:
+ with open('input', 'r') as f:
+ xs = [tuple(map(int, l.split(','))) for l in f.readlines()]
+
+ it = itertools.combinations(xs, 2)
+ it = itertools.starmap(area, it)
+ print(max(it))
+
+
+def area(p: Point, q: Point) -> int:
+ a, b = minmax(p[0], q[0])
+ c, d = minmax(p[1], q[1])
+ return (b - a + 1) * (d - c + 1)
+
+
+def minmax(x: int, y: int) -> tuple[int, int]:
+ return (x, y) if x < y else (y, x)
+
+
+if __name__ == '__main__':
+ main()