diff --git a/09/input b/09/input new file mode 100644 index 0000000..9a7fcf5 --- /dev/null +++ b/09/input @@ -0,0 +1,496 @@ +98302,50003 +98302,51224 +98168,51224 +98168,52447 +98186,52447 +98186,53636 +97714,53636 +97714,54871 +97875,54871 +97875,56010 +97164,56010 +97164,57213 +97068,57213 +97068,58476 +97274,58476 +97274,59728 +97321,59728 +97321,60896 +96940,60896 +96940,62063 +96580,62063 +96580,63178 +96044,63178 +96044,64395 +95871,64395 +95871,65536 +95443,65536 +95443,66593 +94793,66593 +94793,67818 +94599,67818 +94599,68765 +93720,68765 +93720,69885 +93270,69885 +93270,70946 +92694,70946 +92694,72389 +92855,72389 +92855,73409 +92168,73409 +92168,74440 +91512,74440 +91512,75135 +90319,75135 +90319,76590 +90340,76590 +90340,77609 +89661,77609 +89661,78603 +88946,78603 +88946,79150 +87653,79150 +87653,80056 +86856,80056 +86856,80969 +86069,80969 +86069,82283 +85727,82283 +85727,82920 +84627,82920 +84627,83969 +83964,83969 +83964,84620 +82904,84620 +82904,85831 +82367,85831 +82367,86713 +81513,86713 +81513,87151 +80288,87151 +80288,87866 +79306,87866 +79306,88852 +78525,88852 +78525,89142 +77239,89142 +77239,89703 +76163,89703 +76163,90454 +75211,90454 +75211,91706 +74547,91706 +74547,92126 +73378,92126 +73378,92726 +72314,92726 +72314,93055 +71115,93055 +71115,93445 +69958,93445 +69958,93971 +68866,93971 +68866,94264 +67677,94264 +67677,95294 +66771,95294 +66771,95514 +65553,95514 +65553,96011 +64432,96011 +64432,96160 +63204,96160 +63204,96700 +62088,96700 +62088,97050 +60914,97050 +60914,96668 +59587,96668 +59587,97561 +58520,97561 +58520,97113 +57214,97113 +57214,97472 +56042,97472 +56042,97372 +54813,97372 +54813,98058 +53656,98058 +53656,97675 +52414,97675 +52414,98174 +51217,98174 +51217,97538 +49996,97538 +49996,97777 +48785,97777 +48785,97710 +47577,97710 +47577,97588 +46372,97588 +46372,98126 +45102,98126 +45102,97628 +43930,97628 +43930,97893 +42659,97893 +42659,96979 +41576,96979 +41576,97336 +40268,97336 +40268,96764 +39144,96764 +39144,96153 +38046,96153 +38046,96044 +36821,96044 +36821,96133 +35522,96133 +35522,95129 +34570,95129 +34570,94715 +33435,94715 +33435,94476 +32230,94476 +32230,94173 +31039,94173 +31039,93855 +29845,93855 +29845,93309 +28751,93309 +28751,92364 +27866,92364 +27866,91768 +26813,91768 +26813,90974 +25875,90974 +25875,90656 +24654,90656 +24654,90390 +23376,90390 +23376,89775 +22311,89775 +22311,88714 +21567,88714 +21567,88174 +20446,88174 +20446,87381 +19515,87381 +19515,86667 +18517,86667 +18517,85391 +18020,85391 +18020,84587 +17117,84587 +17117,84173 +15821,84173 +15821,83232 +15034,83232 +15034,82204 +14349,82204 +14349,81581 +13206,81581 +13206,80333 +12794,80333 +12794,79174 +12304,79174 +12304,78538 +11129,78538 +11129,77208 +10902,77208 +10902,76567 +9682,76567 +9682,75520 +9049,75520 +9049,74331 +8659,74331 +8659,73210 +8176,73210 +8176,72066 +7748,72066 +7748,71330 +6507,71330 +6507,70084 +6280,70084 +6280,68785 +6215,68785 +6215,67814 +5393,67814 +5393,66621 +5112,66621 +5112,65682 +4109,65682 +4109,64454 +3918,64454 +3918,63076 +4289,63076 +4289,62035 +3502,62035 +3502,60858 +3190,60858 +3190,59573 +3400,59573 +3400,58531 +2382,58531 +2382,57313 +2238,57313 +2238,56105 +2034,56105 +2034,54836 +2406,54836 +2406,53666 +1803,53666 +1803,52448 +1646,52448 +1646,51221 +1674,51221 +1674,50003 +94601,50003 +94601,48785 +2222,48785 +2222,47553 +1818,47553 +1818,46337 +1944,46337 +1944,45177 +2609,45177 +2609,43968 +2666,43968 +2666,42764 +2790,42764 +2790,41575 +3015,41575 +3015,40249 +2568,40249 +2568,39132 +3184,39132 +3184,37906 +3307,37906 +3307,36927 +4324,36927 +4324,35567 +4011,35567 +4011,34363 +4265,34363 +4265,33197 +4640,33197 +4640,32194 +5435,32194 +5435,31142 +6065,31142 +6065,30099 +6695,30099 +6695,28705 +6596,28705 +6596,27761 +7433,27761 +7433,26844 +8288,26844 +8288,25449 +8300,25449 +8300,24396 +8928,24396 +8928,23840 +10314,23840 +10314,22721 +10814,22721 +10814,21729 +11506,21729 +11506,20366 +11722,20366 +11722,19560 +12674,19560 +12674,18574 +13398,18574 +13398,17557 +14096,17557 +14096,17268 +15571,17268 +15571,15972 +15976,15972 +15976,15218 +16942,15218 +16942,14403 +17844,14403 +17844,13244 +18451,13244 +18451,13003 +19837,13003 +19837,12032 +20615,12032 +20615,11292 +21581,11292 +21581,10689 +22643,10689 +22643,10214 +23783,10214 +23783,9256 +24608,9256 +24608,8332 +25475,8332 +25475,7886 +26628,7886 +26628,7649 +27881,7649 +27881,7321 +29068,7321 +29068,6086 +29826,6086 +29826,6310 +31254,6310 +31254,5316 +32154,5316 +32154,4703 +33227,4703 +33227,4507 +34453,4507 +34453,4398 +35695,4398 +35695,3408 +36672,3408 +36672,3522 +37969,3522 +37969,3685 +39256,3685 +39256,3353 +40417,3353 +40417,2886 +41559,2886 +41559,2933 +42793,2933 +42793,2141 +43908,2141 +43908,2680 +45191,2680 +45191,2586 +46392,2586 +46392,2000 +47569,2000 +47569,2086 +48789,2086 +48789,1768 +50003,1768 +50003,2094 +51217,2094 +51217,1726 +52451,1726 +52451,2521 +53618,2521 +53618,2184 +54865,2184 +54865,2001 +56116,2001 +56116,2192 +57327,2192 +57327,2984 +58430,2984 +58430,2640 +59735,2640 +59735,3676 +60752,3676 +60752,3891 +61941,3891 +61941,4311 +63076,4311 +63076,4651 +64231,4651 +64231,4383 +65595,4383 +65595,4870 +66717,4870 +66717,5195 +67900,5195 +67900,6130 +68829,6130 +68829,6542 +69971,6542 +69971,6459 +71361,6459 +71361,7583 +72160,7583 +72160,7855 +73395,7855 +73395,8368 +74511,8368 +74511,9474 +75263,9474 +75263,9687 +76572,9687 +76572,10635 +77402,10635 +77402,11650 +78164,11650 +78164,11759 +79604,11759 +79604,12930 +80230,12930 +80230,13733 +81138,13733 +81138,14741 +81859,14741 +81859,15311 +82978,15311 +82978,16332 +83672,16332 +83672,17169 +84542,17169 +84542,17714 +85740,17714 +85740,18612 +86566,18612 +86566,19436 +87488,19436 +87488,20859 +87651,20859 +87651,21393 +88962,21393 +88962,22570 +89415,22570 +89415,23635 +90009,23635 +90009,24534 +90862,24534 +90862,25593 +91467,25593 +91467,26849 +91716,26849 +91716,27581 +92925,27581 +92925,28721 +93386,28721 +93386,29770 +94036,29770 +94036,31222 +93764,31222 +93764,32377 +94126,32377 +94126,33274 +95169,33274 +95169,34393 +95668,34393 +95668,35730 +95490,35730 +95490,36882 +95855,36882 +95855,38072 +96081,38072 +96081,39252 +96327,39252 +96327,40429 +96585,40429 +96585,41595 +96912,41595 +96912,42771 +97206,42771 +97206,43958 +97461,43958 +97461,45166 +97568,45166 +97568,46336 +98146,46336 +98146,47589 +97604,47589 +97604,48791 +97828,48791 +97828,50003 diff --git a/09/main.go b/09/main.go new file mode 100644 index 0000000..37a1ec6 --- /dev/null +++ b/09/main.go @@ -0,0 +1,50 @@ +package main + +import ( + "fmt" + "math" + "strings" + + "git.z1glr.de/advent-of-code-2025/pkg/aoc" +) + +type Point struct { + X, Y int +} + +func (p Point) Area(p2 Point) float64 { + return math.Abs(float64((p.X - p2.X + 1) * (p.Y - p2.Y + 1))) +} + +func do(test bool) (int, int) { + rows := aoc.ReadFileRows(test) + + points := make([]Point, len(rows)) + + for ii, rr := range rows { + parts := strings.Split(rr, ",") + + points[ii] = Point{ + X: aoc.ParseInt(parts[0]), + Y: aoc.ParseInt(parts[1]), + } + } + + largestArea := 0.0 + + for ii, p1 := range points { + for _, p2 := range points[ii+1:] { + largestArea = math.Max(largestArea, p1.Area(p2)) + } + } + + fmt.Printf("%9.0f\n", largestArea) + + return int(largestArea), 0 +} + +func main() { + if r1, r2 := do(true); r1 == 50 && r2 == 0 { + do(false) + } +} diff --git a/09/test b/09/test new file mode 100644 index 0000000..c8563ea --- /dev/null +++ b/09/test @@ -0,0 +1,8 @@ +7,1 +11,1 +11,7 +9,7 +9,5 +2,5 +2,3 +7,3