aoc

Advent of Code
git clone https://git.pngu.org/aoc
Log | Files | Refs | README

commit 1670612032ab59f7fba57b272b1c4902314af2c8
parent 1890a2aa879fd5e82b4264668ef5ce358ec7ae9d
Author: Jack Sangdahl <jack@pngu.org>
Date:   Wed, 10 Dec 2025 12:05:20 +0100

Day 9 2025

Diffstat:
A2025/9_2025.py | 26++++++++++++++++++++++++++
Adata/9_2025.txt | 496+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 522 insertions(+), 0 deletions(-)

diff --git a/2025/9_2025.py b/2025/9_2025.py @@ -0,0 +1,26 @@ +import shapely + +input = open("data/9_2025.txt") +data = input.read().splitlines() +p = [] + +for i in data: + x, y = [int(x) for x in i.split(",")] + p.append((x, y)) + +polygon = shapely.Polygon(p) +shapely.prepare(polygon) +p1, p2 = 0, 0 + +for i in p: + for j in p: + corners = [i, (i[0], j[1]), j, (j[0], i[1])] + area = abs(i[0] - j[0] + 1) * abs(i[1] - j[1] + 1) + if area > p1: + p1 = area + rect = shapely.Polygon(corners) + if polygon.contains(rect) and area > p2: + p2 = area + +print(p1) +print(p2) diff --git a/data/9_2025.txt b/data/9_2025.txt @@ -0,0 +1,496 @@ +97498,50350 +97498,51566 +97867,51566 +97867,52766 +97596,52766 +97596,54006 +97931,54006 +97931,55187 +97518,55187 +97518,56443 +97775,56443 +97775,57590 +97213,57590 +97213,58740 +96775,58740 +96775,59963 +96730,59963 +96730,61160 +96532,61160 +96532,62325 +96194,62325 +96194,63579 +96166,63579 +96166,64747 +95816,64747 +95816,65738 +94956,65738 +94956,67084 +95104,67084 +95104,68213 +94636,68213 +94636,69347 +94180,69347 +94180,70566 +93903,70566 +93903,71538 +93101,71538 +93101,72410 +92141,72410 +92141,73522 +91652,73522 +91652,74426 +90802,74426 +90802,75931 +90925,75931 +90925,76888 +90149,76888 +90149,77721 +89208,77721 +89208,78796 +88613,78796 +88613,79505 +87542,79505 +87542,80795 +87203,80795 +87203,81587 +86249,81587 +86249,82183 +85097,82183 +85097,83627 +84856,83627 +84856,84032 +83532,84032 +83532,85000 +82781,85000 +82781,86124 +82155,86124 +82155,86868 +81180,86868 +81180,87385 +80026,87385 +80026,88111 +79052,88111 +79052,89185 +78331,89185 +78331,89404 +76996,89404 +76996,90513 +76273,90513 +76273,90778 +75000,90778 +75000,91335 +73923,91335 +73923,92144 +72986,92144 +72986,93037 +72077,93037 +72077,93454 +70918,93454 +70918,93837 +69751,93837 +69751,93869 +68443,93869 +68443,95153 +67650,95153 +67650,94770 +66205,94770 +66205,95477 +65170,95477 +65170,95992 +64057,95992 +64057,96695 +62988,96695 +62988,96706 +61725,96706 +61725,96512 +60431,96512 +60431,97116 +59320,97116 +59320,97218 +58103,97218 +58103,97945 +56982,97945 +56982,97922 +55743,97922 +55743,97873 +54511,97873 +54511,98133 +53308,98133 +53308,97855 +52072,97855 +52072,97610 +50854,97610 +50854,98150 +49644,98150 +49644,98064 +48426,98064 +48426,98149 +47201,98149 +47201,98244 +45967,98244 +45967,97506 +44814,97506 +44814,97672 +43570,97672 +43570,97093 +42429,97093 +42429,96987 +41219,96987 +41219,97272 +39920,97272 +39920,96805 +38773,96805 +38773,96712 +37536,96712 +37536,96394 +36353,96394 +36353,95313 +35414,95313 +35414,95271 +34151,95271 +34151,95006 +32952,95006 +32952,94585 +31807,94585 +31807,93846 +30799,93846 +30799,93745 +29507,93745 +29507,92722 +28650,92722 +28650,92795 +27241,92795 +27241,91741 +26426,91741 +26426,91584 +25105,91584 +25105,90135 +24570,90135 +24570,89768 +23367,89768 +23367,89548 +22037,89548 +22037,88608 +21208,88608 +21208,87649 +20410,87649 +20410,87008 +19365,87008 +19365,85965 +18659,85965 +18659,85572 +17380,85572 +17380,84461 +16753,84461 +16753,83571 +15928,83571 +15928,82940 +14830,82940 +14830,82203 +13821,82203 +13821,80876 +13491,80876 +13491,80002 +12645,80002 +12645,78910 +12075,78910 +12075,78273 +10894,78273 +10894,77284 +10175,77284 +10175,75994 +9916,75994 +9916,75057 +9129,75057 +9129,74085 +8384,74085 +8384,73189 +7483,73189 +7483,71754 +7592,71754 +7592,70817 +6755,70817 +6755,69770 +6120,69770 +6120,68731 +5444,68731 +5444,67415 +5449,67415 +5449,66413 +4655,66413 +4655,65238 +4318,65238 +4318,64163 +3660,64163 +3660,62750 +4160,62750 +4160,61604 +3774,61604 +3774,60546 +2975,60546 +2975,59343 +2767,59343 +2767,58034 +3180,58034 +3180,56884 +2727,56884 +2727,55733 +2167,55733 +2167,54518 +2047,54518 +2047,53271 +2393,53271 +2393,52073 +2128,52073 +2128,50859 +2103,50859 +2103,50332 +94987,50332 +94987,48421 +1783,48421 +1783,47221 +2197,47221 +2197,45964 +1726,45964 +1726,44750 +1910,44750 +1910,43635 +2809,43635 +2809,42413 +2806,42413 +2806,41104 +2394,41104 +2394,40088 +3513,40088 +3513,38804 +3322,38804 +3322,37636 +3663,37636 +3663,36401 +3768,36401 +3768,35351 +4492,35351 +4492,34213 +4906,34213 +4906,33043 +5233,33043 +5233,31770 +5324,31770 +5324,30920 +6430,30920 +6430,29664 +6590,29664 +6590,28395 +6766,28395 +6766,27649 +7971,27649 +7971,26291 +8019,26291 +8019,25590 +9226,25590 +9226,24170 +9233,24170 +9233,23382 +10254,23382 +10254,22024 +10432,22024 +10432,21143 +11304,21143 +11304,20557 +12538,20557 +12538,19224 +12820,19224 +12820,18558 +13918,18558 +13918,17321 +14363,17321 +14363,16912 +15703,16912 +15703,15884 +16384,15884 +16384,14953 +17175,14953 +17175,13961 +17920,13961 +17920,13166 +18848,13166 +18848,12937 +20232,12937 +20232,11530 +20674,11530 +20674,11148 +21909,11148 +21909,10486 +22929,10486 +22929,9812 +23938,9812 +23938,9318 +25058,9318 +25058,8498 +25980,8498 +25980,7909 +27043,7909 +27043,6973 +27927,6973 +27927,6483 +29051,6483 +29051,6446 +30376,6446 +30376,5678 +31366,5678 +31366,5562 +32629,5562 +32629,5018 +33717,5018 +33717,4011 +34659,4011 +34659,4346 +36045,4346 +36045,4059 +37221,4059 +37221,3281 +38271,3281 +38271,3100 +39481,3100 +39481,2674 +40638,2674 +40638,3168 +41962,3168 +41962,2129 +43028,2129 +43028,2448 +44300,2448 +44300,1877 +45465,1877 +45465,2011 +46701,2011 +46701,2358 +47936,2358 +47936,1786 +49134,1786 +49134,1872 +50355,1872 +50355,2164 +51565,2164 +51565,2005 +52789,2005 +52789,2376 +53980,2376 +53980,2525 +55182,2525 +55182,2696 +56379,2696 +56379,2410 +57650,2410 +57650,2919 +58797,2919 +58797,3411 +59933,3411 +59933,2910 +61294,2910 +61294,3912 +62296,3912 +62296,4389 +63416,4389 +63416,3917 +64833,3917 +64833,4674 +65867,4674 +65867,5492 +66858,5492 +66858,5141 +68304,5141 +68304,6252 +69157,6252 +69157,6291 +70474,6291 +70474,7304 +71335,7304 +71335,7519 +72591,7519 +72591,8464 +73457,8464 +73457,8940 +74580,8940 +74580,9586 +75606,9586 +75606,10247 +76622,10247 +76622,10724 +77769,10724 +77769,11508 +78705,11508 +78705,12189 +79716,12189 +79716,12907 +80703,12907 +80703,13607 +81711,13607 +81711,14273 +82760,14273 +82760,15159 +83612,15159 +83612,16074 +84430,16074 +84430,17068 +85160,17068 +85160,17882 +86081,17882 +86081,19054 +86591,19054 +86591,19828 +87565,19828 +87565,20678 +88463,20678 +88463,22125 +88554,22125 +88554,22930 +89510,22930 +89510,24078 +89971,24078 +89971,25154 +90525,25154 +90525,26127 +91246,26127 +91246,27052 +92072,27052 +92072,27955 +92972,27955 +92972,28997 +93627,28997 +93627,30158 +94037,30158 +94037,31293 +94496,31293 +94496,32429 +94947,32429 +94947,33493 +95601,33493 +95601,34724 +95792,34724 +95792,35890 +96162,35890 +96162,37228 +95912,37228 +95912,38335 +96462,38335 +96462,39507 +96780,39507 +96780,40595 +97543,40595 +97543,41916 +97104,41916 +97104,43143 +97075,43143 +97075,44241 +98041,44241 +98041,45525 +97482,45525 +97482,46742 +97402,46742 +97402,47937 +97630,47937 +97630,49138 +97978,49138 +97978,50350