From cbbd4abf57a7861d68d2c723fd192e4904e893a7 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Tue, 9 Dec 2025 13:14:00 +0000 Subject: [PATCH] 2025: d09: ex1: add solution --- 2025/d09/ex1/ex1.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100755 2025/d09/ex1/ex1.py diff --git a/2025/d09/ex1/ex1.py b/2025/d09/ex1/ex1.py new file mode 100755 index 0000000..3aa94f9 --- /dev/null +++ b/2025/d09/ex1/ex1.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python + +import itertools +import sys +from typing import NamedTuple + + +class Point(NamedTuple): + x: int + y: int + + +def solve(input: list[str]) -> int: + def parse(input: list[str]) -> list[Point]: + return [Point(*map(int, line.split(","))) for line in input] + + def rectangle_area(p: Point, other: Point) -> int: + dx = abs(p.x - other.x) + dy = abs(p.y - other.y) + return (dx + 1) * (dy + 1) + + tiles = parse(input) + return max(rectangle_area(a, b) for a, b in itertools.combinations(tiles, 2)) + + +def main() -> None: + input = sys.stdin.read().splitlines() + print(solve(input)) + + +if __name__ == "__main__": + main()