Explorar el Código

Solve day 9 (not general)

Taddeus Kroes hace 2 meses
padre
commit
0cee721fca
Se han modificado 2 ficheros con 515 adiciones y 0 borrados
  1. 19 0
      2025/09_tiles.py
  2. 496 0
      2025/input/9

+ 19 - 0
2025/09_tiles.py

@@ -0,0 +1,19 @@
+#!/usr/bin/env python3
+import sys
+from itertools import combinations
+
+def area(xa, ya, xb, yb):
+    return (abs(xa - xb) + 1) * (abs(ya - yb) + 1)
+
+def fits(red, xa, ya, xb, yb):
+    xmin, xmax = (xa, xb) if xa < xb else (xb, xa)
+    ymin, ymax = (ya, yb) if ya < yb else (yb, ya)
+    return not any(xmin < x < xmax and ymin < y < ymax for x, y in red)
+
+def maxrect(half):
+    a = half.pop()
+    return max(area(*a, *b) for b in half if fits(half, *a, *b))
+
+red = [tuple(map(int, line.split(','))) for line in sys.stdin]
+print(max(area(*a, *b) for a, b in combinations(red, 2)))
+print(max(maxrect(red[:249]), maxrect(red[-2:248:-1])))

+ 496 - 0
2025/input/9

@@ -0,0 +1,496 @@
+98275,50287
+98275,51515
+98414,51515
+98414,52719
+97965,52719
+97965,53917
+97688,53917
+97688,55097
+97323,55097
+97323,56370
+97744,56370
+97744,57554
+97420,57554
+97420,58804
+97493,58804
+97493,59889
+96709,59889
+96709,61017
+96226,61017
+96226,62420
+96820,62420
+96820,63512
+96180,63512
+96180,64718
+95950,64718
+95950,65802
+95345,65802
+95345,66970
+94995,66970
+94995,67945
+94160,67945
+94160,69096
+93778,69096
+93778,70456
+93831,70456
+93831,71405
+92987,71405
+92987,72453
+92367,72453
+92367,73754
+92202,73754
+92202,74534
+91115,74534
+91115,75810
+90864,75810
+90864,76761
+90084,76761
+90084,77514
+89032,77514
+89032,78811
+88749,78811
+88749,79352
+87456,79352
+87456,80871
+87402,80871
+87402,81756
+86548,81756
+86548,82218
+85236,82218
+85236,83332
+84649,83332
+84649,83982
+83579,83982
+83579,85213
+83075,85213
+83075,85982
+82121,85982
+82121,86830
+81238,86830
+81238,87240
+79997,87240
+79997,88437
+79387,88437
+79387,88778
+78121,88778
+78121,89292
+77002,89292
+77002,90201
+76152,90201
+76152,91079
+75266,91079
+75266,91820
+74283,91820
+74283,91886
+72923,91886
+72923,92463
+71860,92463
+71860,92797
+70677,92797
+70677,93423
+69639,93423
+69639,94586
+68819,94586
+68819,94354
+67411,94354
+67411,95516
+66549,95516
+66549,95496
+65249,95496
+65249,95881
+64095,95881
+64095,95982
+62861,95982
+62861,96327
+61700,96327
+61700,96775
+60560,96775
+60560,96910
+59349,96910
+59349,96971
+58130,96971
+58130,97197
+56942,97197
+56942,97481
+55759,97481
+55759,98169
+54608,98169
+54608,97605
+53340,97605
+53340,97707
+52134,97707
+52134,98275
+50935,98275
+50935,97819
+49714,97819
+49714,98399
+48484,98399
+48484,97876
+47285,97876
+47285,97752
+46077,97752
+46077,97675
+44864,97675
+44864,97136
+43710,97136
+43710,97388
+42450,97388
+42450,97479
+41197,97479
+41197,96744
+40103,96744
+40103,96787
+38848,96787
+38848,96106
+37768,96106
+37768,95938
+36558,95938
+36558,95891
+35300,95891
+35300,95569
+34119,95569
+34119,95325
+32905,95325
+32905,94724
+31824,94724
+31824,94256
+30695,94256
+30695,93348
+29768,93348
+29768,92846
+28664,92846
+28664,92728
+27355,92728
+27355,91798
+26472,91798
+26472,91451
+25264,91451
+25264,90710
+24286,90710
+24286,90142
+23199,90142
+23199,88834
+22625,88834
+22625,88876
+21094,88876
+21094,88066
+20169,88066
+20169,87024
+19441,87024
+19441,86585
+18211,86585
+18211,85323
+17702,85323
+17702,84861
+16463,84861
+16463,83947
+15645,83947
+15645,83058
+14805,83058
+14805,81898
+14267,81898
+14267,81080
+13355,81080
+13355,80302
+12381,80302
+12381,79179
+11835,79179
+11835,78439
+10783,78439
+10783,77255
+10338,77255
+10338,76369
+9465,76369
+9465,75274
+8907,75274
+8907,74085
+8520,74085
+8520,72834
+8276,72834
+8276,72057
+7152,72057
+7152,70931
+6676,70931
+6676,69864
+6077,69864
+6077,68666
+5777,68666
+5777,67484
+5459,67484
+5459,66349
+5034,66349
+5034,65150
+4798,65150
+4798,64119
+4042,64119
+4042,63019
+3450,63019
+3450,61819
+3202,61819
+3202,60584
+3121,60584
+3121,59426
+2702,59426
+2702,58248
+2342,58248
+2342,56963
+2659,56963
+2659,55813
+2071,55813
+2071,54546
+2477,54546
+2477,53328
+2559,53328
+2559,52144
+2077,52144
+2077,50934
+1774,50934
+1774,50265
+94543,50265
+94543,48498
+2032,48498
+2032,47304
+2454,47304
+2454,46033
+1717,46033
+1717,44898
+2639,44898
+2639,43588
+1944,43588
+1944,42397
+2276,42397
+2276,41268
+2901,41268
+2901,40075
+3123,40075
+3123,38933
+3570,38933
+3570,37584
+3200,37584
+3200,36529
+3961,36529
+3961,35242
+3927,35242
+3927,34255
+4819,34255
+4819,33149
+5322,33149
+5322,31975
+5646,31975
+5646,30983
+6406,30983
+6406,29681
+6464,29681
+6464,28522
+6866,28522
+6866,27544
+7628,27544
+7628,26455
+8170,26455
+8170,25395
+8767,25395
+8767,24473
+9585,24473
+9585,23118
+9736,23118
+9736,22102
+10424,22102
+10424,21127
+11168,21127
+11168,20450
+12291,20450
+12291,19373
+12893,19373
+12893,18699
+13975,18699
+13975,17858
+14847,17858
+14847,17052
+15750,17052
+15750,15814
+16219,15814
+16219,15053
+17175,15053
+17175,14045
+17903,14045
+17903,13770
+19271,13770
+19271,12525
+19813,12525
+19813,11794
+20789,11794
+20789,11066
+21766,11066
+21766,10769
+23040,10769
+23040,9656
+23755,9656
+23755,9034
+24803,9034
+24803,8107
+25674,8107
+25674,7507
+26745,7507
+26745,7296
+28016,7296
+28016,7109
+29277,7109
+29277,6092
+30141,6092
+30141,5457
+31198,5457
+31198,5060
+32358,5060
+32358,4637
+33506,4637
+33506,4350
+34699,4350
+34699,3641
+35758,3641
+35758,3998
+37133,3998
+37133,3134
+38163,3134
+38163,3485
+39497,3485
+39497,3240
+40680,3240
+40680,2654
+41805,2654
+41805,2742
+43048,2742
+43048,2467
+44234,2467
+44234,2282
+45434,2282
+45434,1958
+46629,1958
+46629,2098
+47856,2098
+47856,2062
+49071,2062
+49071,2395
+50283,2395
+50283,2179
+51497,2179
+51497,2397
+52698,2397
+52698,2387
+53911,2387
+53911,2614
+55104,2614
+55104,2190
+56378,2190
+56378,2374
+57586,2374
+57586,2897
+58732,2897
+58732,2628
+60029,2628
+60029,3704
+61034,3704
+61034,3124
+62435,3124
+62435,4186
+63404,4186
+63404,4246
+64655,4246
+64655,4663
+65798,4663
+65798,5027
+66961,5027
+66961,5154
+68224,5154
+68224,5771
+69293,5771
+69293,6583
+70263,6583
+70263,6852
+71484,6852
+71484,7464
+72542,7464
+72542,7871
+73712,7871
+73712,8922
+74511,8922
+74511,9456
+75608,9456
+75608,9874
+76789,9874
+76789,10739
+77674,10739
+77674,11604
+78548,11604
+78548,11980
+79793,11980
+79793,13353
+80246,13353
+80246,13475
+81735,13475
+81735,14327
+82617,14327
+82617,15228
+83449,15228
+83449,16249
+84155,16249
+84155,16927
+85209,16927
+85209,17788
+86083,17788
+86083,18880
+86689,18880
+86689,19707
+87606,19707
+87606,20628
+88415,20628
+88415,22106
+88463,22106
+88463,23037
+89235,23037
+89235,23695
+90435,23695
+90435,24608
+91283,24608
+91283,26018
+91299,26018
+91299,26730
+92518,26730
+92518,27992
+92750,27992
+92750,29081
+93295,29081
+93295,30206
+93764,30206
+93764,31212
+94511,31212
+94511,32436
+94741,32436
+94741,33530
+95296,33530
+95296,34904
+95039,34904
+95039,35788
+96260,35788
+96260,37173
+95859,37173
+95859,38216
+96656,38216
+96656,39472
+96628,39472
+96628,40550
+97414,40550
+97414,41756
+97623,41756
+97623,43033
+97358,43033
+97358,44220
+97641,44220
+97641,45404
+98036,45404
+98036,46657
+97643,46657
+97643,47837
+98340,47837
+98340,49069
+98028,49069
+98028,50287