diff --git a/2025/08/README.md b/2025/08/README.md index 1a21ec0..7bf0166 100644 --- a/2025/08/README.md +++ b/2025/08/README.md @@ -57,3 +57,11 @@ This process continues for a while, and the Elves are concerned that they don't After making the ten shortest connections, there are 11 circuits: one circuit which contains _5_ junction boxes, one circuit which contains _4_ junction boxes, two circuits which contain _2_ junction boxes each, and seven circuits which each contain a single junction box. Multiplying together the sizes of the three largest circuits (5, 4, and one of the circuits of size 2) produces _`40`_. Your list contains many junction boxes; connect together the _1000_ pairs of junction boxes which are closest together. Afterward, _what do you get if you multiply together the sizes of the three largest circuits?_ + +### Part Two + +The Elves were right; they _definitely_ don't have enough extension cables. You'll need to keep connecting junction boxes together until they're all in _one large circuit_. + +Continuing the above example, the first connection which causes all of the junction boxes to form a single circuit is between the junction boxes at `216,146,977` and `117,168,530`. The Elves need to know how far those junction boxes are from the wall so they can pick the right extension cable; multiplying the X coordinates of those two junction boxes (`216` and `117`) produces _`25272`_. + +Continue connecting the closest unconnected pairs of junction boxes together until they're all in the same circuit. _What do you get if you multiply together the X coordinates of the last two junction boxes you need to connect?_ diff --git a/2025/08/input b/2025/08/input new file mode 100644 index 0000000..e3b6ebf --- /dev/null +++ b/2025/08/input @@ -0,0 +1,1000 @@ +8558,1355,27987 +51828,64554,61771 +21092,96778,69513 +84219,58520,31084 +97464,11470,75659 +88825,36460,36857 +61817,65439,18947 +29437,77204,70126 +9811,89020,52272 +59901,40633,91295 +6987,80336,91986 +63310,78431,65957 +52158,57483,71820 +21803,75753,32227 +95984,3751,42174 +64950,23485,89640 +67800,10887,36758 +25967,60371,22749 +14510,35,56129 +82069,51656,17895 +43825,85193,36502 +21384,31901,23763 +70821,99276,40784 +1336,72798,98198 +19043,11095,55249 +17895,65556,42740 +98539,46018,48236 +94258,10685,2282 +9216,92896,78108 +87131,35812,11998 +96799,71501,12643 +41046,42435,91508 +92652,86239,92538 +83656,80720,60852 +76794,85098,93363 +57597,71905,41567 +79540,70014,13489 +88534,81766,63802 +3632,64031,12058 +60795,3229,53302 +75227,33480,12779 +74138,11896,63415 +34000,69529,57337 +66253,32751,52281 +29832,54344,76901 +29827,16184,96817 +32076,50857,13028 +49751,64661,46997 +93715,95391,21951 +70071,93137,30728 +50467,39905,60656 +39883,37708,49815 +6196,31364,52253 +21460,20949,6132 +40240,41311,64536 +83351,60710,45399 +79921,61765,1825 +84002,88985,51530 +78113,94443,81118 +16455,24923,28133 +88189,13613,59372 +21394,28221,76822 +92191,11494,41154 +34319,46816,86891 +60488,77726,61305 +20063,98984,59240 +25797,72775,42845 +13367,99145,36505 +72237,6972,79517 +88396,65049,71385 +96457,8010,11471 +69412,88347,28710 +18273,81104,16348 +45469,20275,39580 +1433,87634,32022 +23018,7752,99704 +62445,73926,6546 +77887,9443,10859 +58526,47266,37959 +61812,37877,59402 +94915,49841,71861 +58262,6002,18685 +90889,32442,44232 +95060,24416,11757 +27552,41469,58346 +8636,44702,82605 +4945,70462,84890 +64755,62300,33428 +50231,82566,38097 +25743,10883,34625 +33071,96816,54697 +27933,69691,76434 +26998,73280,78152 +35745,25876,6272 +26939,10513,45773 +42120,91508,1147 +61726,62101,69958 +17349,40786,23504 +76842,35407,11029 +47074,19347,70108 +25197,32178,97226 +81871,21139,72307 +78684,82787,8516 +36165,17842,27034 +37085,62681,70523 +64447,20522,13905 +78618,58174,78265 +86397,69789,64405 +1083,99541,19198 +4474,61673,34783 +49430,26443,55150 +71437,79922,17994 +23895,57113,49764 +47548,63294,20400 +19430,42432,18043 +13108,45180,67272 +19887,93510,21983 +12186,26333,91834 +9655,97454,43414 +47118,15770,22003 +34200,59868,76038 +38922,66367,58205 +87213,8401,57638 +43866,43130,21676 +65804,37252,55708 +87996,1885,23133 +9245,48156,39872 +57644,68213,5080 +56611,6261,1366 +15379,70493,66800 +83799,50948,463 +92613,24865,41042 +37854,72400,44491 +30954,96102,74202 +80413,21140,68496 +3449,70664,71700 +5803,16398,81867 +2193,5511,30386 +76747,80431,47234 +66976,61782,59903 +86718,91043,76163 +91456,39225,82149 +69631,37839,4719 +9983,33168,60283 +58097,25516,51926 +14717,1261,17573 +23682,95182,36602 +91272,53090,36894 +17681,72184,87192 +47992,89519,26573 +91340,73903,82975 +63910,87484,21260 +42682,79574,44708 +29141,71585,31515 +51190,87175,75463 +79496,28978,65302 +4076,55597,20082 +55270,60713,62929 +61500,84688,95628 +486,35512,70462 +653,96662,82667 +38222,79646,64921 +71584,70816,12456 +11468,50299,23827 +46719,67364,47378 +85223,12987,53551 +31275,74741,42873 +35561,77973,5254 +88652,80801,89457 +31441,65190,92010 +69023,22529,13332 +79496,9263,37006 +77822,27057,20256 +83232,95034,53797 +215,95100,46852 +29551,79597,74749 +90264,45121,99394 +82163,58601,1386 +81452,25941,23945 +71430,25902,10989 +42716,16665,10234 +72164,92350,37474 +44263,1557,68718 +98888,53368,8938 +6661,56209,62217 +26788,22706,80226 +46759,33989,55522 +38884,22344,65849 +99488,75832,70110 +56466,26483,56709 +46745,15690,64702 +53097,19504,34197 +28154,50545,59294 +82693,51289,861 +70293,85137,97681 +66718,40950,640 +55228,6803,44640 +7540,61389,26852 +70186,98600,86515 +32601,14888,34874 +40363,97512,62828 +72988,13125,35893 +6535,46143,57329 +11500,53382,1642 +8052,25706,12672 +50017,6350,6783 +53433,74658,72525 +53717,95538,62079 +92621,91358,81755 +6631,62086,37567 +30239,98459,36149 +12718,85469,37997 +86472,84411,40689 +16304,60064,9150 +61958,29423,89108 +33005,88497,41728 +52072,46770,47156 +2434,37497,60838 +1761,39343,95778 +932,57443,81969 +71902,9162,72642 +93880,17609,23616 +59581,52092,66486 +63261,10135,94131 +84544,49404,95936 +44774,54376,87888 +7531,32125,18116 +31816,10726,43501 +56179,58512,72924 +56377,60860,69066 +7069,98385,30045 +47889,75424,47036 +42897,73716,14374 +17529,30604,24419 +79819,12862,48320 +64226,60869,20574 +24013,93870,78046 +45277,73771,8073 +27113,14710,56790 +69254,77100,3048 +4884,25882,2821 +80823,17254,84989 +69917,42703,10185 +73942,81625,38066 +60100,80985,98274 +54404,66609,58494 +6181,88787,87054 +69835,14904,10743 +85959,99345,19466 +32608,89472,66070 +65782,86818,7430 +52667,87278,78351 +62414,240,42950 +63949,57752,23211 +31545,75611,93941 +62585,3243,86506 +57566,44740,54477 +33926,18252,21156 +8945,1609,70299 +84125,39503,96846 +96743,37433,22673 +74795,48127,29325 +86518,90635,57242 +58893,80657,41301 +28530,54407,76198 +72880,78332,2409 +76140,22182,74499 +15787,60942,65023 +53106,54956,7726 +7298,31624,23006 +48486,64596,4652 +8885,86313,83041 +96096,44698,78290 +97920,54181,17765 +48623,61688,49093 +55756,90524,92073 +61970,5884,95341 +51400,15040,5273 +52800,16126,71115 +89513,57572,91137 +43957,86496,40772 +65974,84628,71293 +96535,63142,1355 +19796,65276,44526 +97489,50448,58353 +87141,73108,17572 +923,19562,87006 +51006,38294,95047 +57265,86071,98866 +25303,37220,7802 +56962,82699,19929 +33223,59939,10504 +36053,65738,14732 +36056,38156,93897 +3423,25867,37544 +41685,70070,33266 +39238,54406,91422 +86598,25704,70294 +82460,31147,72779 +56591,59168,42163 +51449,5175,71239 +54900,19662,88519 +57496,34567,39508 +75046,67972,23216 +50300,23563,35359 +28979,78336,869 +81843,57476,93489 +52588,77425,56038 +12802,64392,55092 +43352,66736,64980 +64651,13901,56778 +81190,58654,35871 +49097,73407,44163 +39891,30750,71958 +66933,24901,48388 +44517,78884,76567 +8179,44683,55040 +6998,26026,93150 +97031,25073,23584 +97311,81827,41698 +94829,21210,76958 +99842,55177,25579 +57732,5592,97779 +33977,83740,73042 +45374,73946,47665 +95877,9034,46440 +20542,24567,63610 +98895,26112,76632 +72427,145,69943 +93986,47646,23317 +84118,5627,7226 +47054,78287,64519 +81875,48341,85971 +27289,66093,21141 +79543,95935,84189 +54666,87179,68300 +26022,10638,64266 +63223,76508,69276 +54704,26292,29399 +64355,73940,50927 +8372,95445,75485 +99266,69451,13961 +41332,99254,87818 +4005,99868,63603 +31953,70798,3427 +97361,49293,62050 +42871,71883,63426 +60607,85106,71677 +54398,31669,58093 +8296,34946,92398 +88942,22683,78107 +5676,6604,8992 +10241,18808,29294 +22258,80337,59999 +66266,27517,6949 +34373,17378,95529 +845,93039,65765 +1331,60682,75490 +38033,76084,43974 +91195,81958,54433 +62984,31209,58643 +41492,39044,6729 +9214,53234,46326 +47557,75977,7251 +72011,59196,95043 +18053,31939,9751 +37694,81624,84552 +74964,37596,81041 +39602,16422,71820 +61230,27814,60608 +57470,72796,82419 +17925,19727,77848 +39796,65514,88858 +14569,34190,76795 +95960,90588,87740 +26566,83118,90736 +62102,22608,91737 +54380,79855,3556 +81704,77073,63355 +15766,98006,85673 +4306,7772,94722 +4370,30673,5158 +48659,89340,97688 +98218,16456,44063 +98764,63163,74843 +6916,80025,69994 +19788,12823,91437 +8126,17265,95667 +18807,87603,97774 +6375,97395,79240 +64932,50401,768 +22295,62475,89393 +51657,11656,76056 +35494,96749,37027 +68691,87889,89088 +70679,89580,3326 +2433,25228,3392 +53290,66722,43099 +54334,37103,25673 +50254,70394,93282 +22341,50937,86857 +71002,69786,51304 +4242,93491,48209 +48353,18641,8637 +31396,78498,67244 +86205,10913,85954 +8881,82040,91288 +94964,19309,57597 +40922,78435,79801 +67664,27218,36946 +1443,23282,48812 +91230,78156,3349 +18737,54346,40692 +43560,98979,69819 +78757,30775,45835 +63566,66839,94303 +86263,71294,23695 +21602,5551,32086 +29279,57209,16048 +22040,34379,32326 +83705,79987,16303 +44038,84213,17575 +42591,72802,22528 +27447,8389,23426 +89765,1088,61489 +66486,19157,39189 +42127,76015,89958 +5693,57778,26590 +74902,17025,22050 +63890,25475,22101 +92279,71716,90598 +69780,93912,63691 +1482,58192,67661 +56931,69533,46296 +84854,79270,9307 +89884,59333,1832 +46140,51641,23393 +19394,13068,63717 +8328,55838,6040 +79281,75358,98754 +5713,755,23446 +52779,962,82673 +70634,96412,59773 +68659,74036,71743 +90736,78585,49961 +84814,59527,34241 +54467,39278,63754 +21443,31093,24654 +3341,82285,66703 +79183,97164,13075 +79235,6090,7621 +88147,98343,40459 +18566,15467,67953 +70060,11434,22075 +15476,33650,16281 +30236,35501,88584 +58642,73368,49927 +59220,14383,32577 +65329,69222,12718 +10678,37132,70640 +1947,97085,6889 +85341,60399,11698 +76551,94011,92124 +55009,97901,61337 +91654,49985,72214 +99983,87102,88275 +26717,50314,94039 +8661,7455,57498 +16008,40955,76354 +28038,82563,54083 +48627,29425,7488 +95151,56891,90671 +2655,97673,83688 +68960,85379,54971 +94267,65396,46288 +90155,7889,17519 +92418,31128,26440 +30216,76866,99232 +53265,62397,66543 +8307,68884,92084 +67159,19087,21252 +85621,17106,7595 +50603,90959,16423 +48056,18435,24150 +74205,27053,89057 +81434,27750,49480 +14319,66012,13321 +54968,67890,93354 +94777,79928,36965 +26991,89590,2359 +4803,88117,68066 +28903,97432,88063 +51313,93964,48633 +8341,45789,64568 +87202,25137,40631 +90293,24473,65134 +60797,21213,24095 +29454,30868,87182 +53536,19452,16696 +95851,31668,99626 +94610,53912,10577 +91816,59286,43761 +24687,84332,44384 +26065,45762,78150 +56487,75718,38966 +68531,38653,65134 +90246,58561,99852 +63331,87751,25429 +99873,33322,85043 +60617,33829,53089 +48761,1438,48458 +8984,21381,78972 +65098,74619,86114 +62031,16774,85894 +57351,59190,3675 +4125,89599,2665 +70656,57786,80465 +25144,39855,10098 +70085,20804,32451 +88527,18631,66652 +66702,65141,84324 +52669,69188,7899 +63104,6758,16406 +55079,75040,1390 +82299,53045,56129 +36579,90725,54542 +2870,22084,11098 +96544,13266,39725 +30612,66824,15612 +83747,41324,63395 +95809,27943,88209 +45046,47183,97848 +92118,41336,22253 +75061,35607,21502 +63789,89193,40086 +31543,9389,67180 +69040,72594,78052 +85883,27459,70064 +63437,83694,44675 +37846,33163,22073 +92914,74298,99510 +85921,12681,93214 +18602,79767,58165 +33328,53739,17921 +99974,51329,16604 +44046,1276,66147 +66554,17597,28865 +24209,94206,9855 +48459,17585,57905 +95200,48731,37687 +49625,57913,20177 +960,30967,93624 +12305,74440,1209 +76564,75011,33554 +9611,96703,2954 +511,98108,47151 +44761,31135,45752 +61074,82467,29539 +21109,84108,24439 +28506,35445,82819 +88720,45218,91716 +39849,48723,31502 +29771,54049,2072 +97118,42524,7391 +93232,77575,53725 +17485,19244,42172 +30326,14871,26629 +54684,65607,49532 +61268,44017,17187 +82360,83520,84600 +61665,75125,10114 +31912,87490,86181 +23043,68883,86563 +98885,82004,8358 +89386,46317,87858 +21804,31392,12226 +37790,90234,38326 +92035,91266,53596 +1052,4729,24544 +64401,77357,72606 +96617,71963,26816 +80176,64151,62495 +9959,92491,51404 +15066,84727,46783 +14672,56771,19890 +26426,1736,85661 +39823,13437,34564 +95369,79319,82789 +78631,69887,87020 +19588,72085,4442 +86453,87267,91413 +53517,13536,62841 +22645,59333,66938 +53073,85457,93581 +64809,65350,45379 +67281,19512,88825 +21642,63875,56186 +37792,6902,10115 +85690,70694,13082 +69134,35966,58009 +24969,66969,75724 +71533,11068,14576 +71941,80325,17690 +74261,88613,96436 +66595,24992,3184 +31079,24969,83004 +22669,21559,6484 +30768,71569,26127 +58012,41996,84940 +70986,53807,76924 +23451,66841,50030 +69478,72725,95083 +91179,65705,50832 +32559,26658,75600 +18502,32977,12456 +13244,23591,89491 +88168,63344,60769 +51688,33451,86485 +49504,78798,97212 +66495,27619,54931 +35569,87808,87228 +29781,95584,79879 +97308,45689,97507 +71690,28898,68146 +31453,99244,30643 +8438,29744,10280 +63600,53767,64503 +16027,53708,49235 +64058,72872,30798 +87604,30627,5679 +6273,94883,66101 +48078,73580,73224 +90037,7343,61141 +6005,32837,16839 +5684,4770,53159 +17331,62800,3070 +8695,79488,13326 +80312,77103,9234 +29902,39330,4330 +50695,23140,7165 +52277,49408,15411 +80048,30133,62377 +80921,74067,53388 +98204,20737,63571 +62980,56600,2335 +14040,12079,74482 +15691,26494,49172 +7969,76422,71297 +79402,13800,24818 +72569,9123,88173 +25471,15753,85568 +69119,2482,52949 +50066,74131,50678 +19466,71619,86962 +34002,4019,11924 +5528,22087,20802 +63157,41634,68214 +58270,68411,17633 +3340,54134,79724 +25496,8032,3565 +80591,10857,37111 +15574,25161,74190 +59871,16593,53284 +69814,55421,68543 +83985,52344,70293 +37475,76113,11557 +20542,66902,56803 +37435,58713,84164 +40404,25134,46838 +87916,3764,17388 +88796,27704,10797 +62812,1666,22508 +29235,60880,7913 +62344,96111,57039 +34271,66054,33180 +28457,23999,8174 +7878,66616,35692 +89396,75098,67227 +82235,78126,16919 +618,89782,46806 +44951,72273,50128 +26113,18449,29162 +35689,95296,12142 +3848,18911,68498 +94397,66478,25563 +57997,28408,21013 +81630,37268,17999 +3573,27727,63216 +93396,29605,53824 +79962,80168,75313 +95187,30378,52719 +45199,61404,68821 +29795,69922,92111 +54188,87452,40249 +32188,19562,10762 +27609,46790,59189 +71333,78632,92432 +48847,47414,29488 +78589,58292,17314 +40550,87814,18718 +77114,47936,28538 +50912,8648,6050 +19485,26127,53647 +15197,8439,39030 +96230,48462,68291 +71795,22783,94931 +69227,92503,29156 +58071,45223,1309 +61124,45109,25147 +43148,31754,85407 +39934,2372,47647 +40508,12223,68336 +38170,548,71678 +89716,56825,76665 +1911,88172,55242 +61743,65220,11464 +32438,69017,92907 +1358,9093,10808 +5456,26875,84708 +29543,60982,49555 +93129,77977,24191 +61379,47190,92706 +96084,90490,76251 +68727,6675,77318 +48472,64935,13836 +55916,54345,72277 +95890,11296,58482 +39456,54986,40444 +94192,99514,20607 +84479,10663,56148 +17275,54738,80267 +35609,23535,74267 +17194,61081,38334 +46350,46111,66500 +129,36756,27748 +98990,89070,80264 +97864,9215,25823 +53586,97204,50531 +55765,75583,66524 +87423,44942,26422 +95827,95420,86098 +14844,57636,45672 +18034,57633,16600 +42417,49452,78066 +2380,88427,76037 +36748,8716,17577 +15000,4928,52374 +63341,9495,98802 +93682,43363,82501 +55337,2064,82104 +28918,32904,1048 +72893,10144,21204 +67131,86776,68443 +97198,94455,65988 +71407,40354,95180 +24672,69101,39857 +45549,6669,38631 +77297,35786,90687 +70282,34786,53202 +65373,34811,64960 +51002,32361,58397 +15474,98586,3379 +90026,70273,30730 +72811,1815,55851 +16992,28473,62092 +73087,50316,40993 +80352,13966,55670 +86518,19374,64210 +42979,48014,64993 +45177,51176,87452 +29446,98129,45298 +1599,18511,49034 +47219,50424,29396 +24111,2235,29686 +54787,21217,63482 +58400,51937,79664 +60020,28224,65169 +34552,32360,39478 +57929,2629,20220 +89883,57135,14959 +65433,1933,35613 +16435,47733,34892 +44240,49510,64773 +20044,16169,20759 +62757,5809,40248 +84785,30134,19159 +38104,98373,46547 +69298,20758,79493 +31493,87300,172 +5146,45050,29897 +31343,46151,69094 +39,34364,46230 +30762,19698,4853 +45009,11410,70271 +41457,40636,31033 +27222,65492,16295 +79114,12338,59251 +77305,23388,69199 +24267,81074,15148 +4905,40825,92839 +96956,99330,66565 +75938,31019,47699 +30350,68751,5787 +4033,82003,12144 +47749,33455,37383 +54350,94560,56771 +89057,66012,56176 +98310,27093,70360 +60196,89782,62588 +14091,5845,71423 +63468,37870,23813 +94826,81078,23961 +94259,17730,65335 +7419,26699,83052 +72177,99553,69068 +56506,60864,33817 +31248,18163,50120 +58463,74503,42829 +86760,6652,87975 +70477,19017,58677 +74993,74914,85078 +38256,86385,27734 +78798,55734,79755 +41742,82280,66839 +46685,55756,38220 +38297,75899,21934 +67076,38420,80803 +51428,74181,62279 +6325,20206,96613 +64996,14316,65949 +69713,44445,8384 +3915,75076,37871 +92764,18373,92024 +87808,91702,42916 +3515,88618,57204 +47320,6804,83565 +64092,23679,98105 +75049,57503,19409 +43317,56826,37297 +20076,66440,97079 +6980,80610,54430 +66636,58994,38000 +97635,43987,27357 +31410,10423,19056 +87004,57377,60203 +12123,55158,31526 +54711,69531,81001 +55291,28331,60698 +37511,70349,36527 +93686,33892,56528 +22329,71731,93482 +5546,96570,8479 +23723,5252,61613 +3363,89837,52427 +70877,94123,78793 +89480,19324,64545 +55964,27509,95380 +1280,13610,78663 +36501,93497,41743 +11065,39090,27681 +11340,53878,741 +92316,4240,95597 +67320,13758,99667 +20064,19341,55820 +94378,29755,38080 +37717,91243,90151 +20146,33920,3113 +50575,64501,87151 +37345,22105,94702 +83758,18121,20838 +34121,46453,73975 +71598,57748,345 +67141,23277,95429 +34693,62552,78202 +5289,67547,81648 +49971,3763,4470 +95153,40489,85072 +11717,80233,62491 +12893,18961,26916 +48386,73586,92623 +95350,91503,94463 +92203,19834,49887 +22464,7441,28178 +74741,51966,2656 +55203,25569,32746 +6090,7922,26379 +80772,80038,88510 +90362,39069,21502 +96148,71595,84137 +54611,27025,83216 +69594,42898,35541 +82582,24294,31216 +41464,59846,41913 +9671,95372,60914 +85145,13015,96288 +26510,85367,42667 +84389,73010,11062 +50984,96927,85920 +60387,64870,30823 +56591,37096,81695 +15346,19715,14447 +17389,97272,5545 +7189,67518,86259 +50349,26732,40719 +8205,940,20342 +3080,59638,42992 +99914,27983,92491 +97116,57329,98171 +56320,13921,32219 +3318,34259,2732 +92963,65907,12662 +35361,68531,17680 +6992,33819,47033 +27663,38986,32076 +45164,48356,85285 +69971,73943,29107 +34400,50573,42039 +33101,38181,59604 +74415,57458,92813 +90889,96012,73393 +51872,49655,66612 +86517,55421,65620 +22114,35575,51522 +60095,11155,53083 +13417,91184,35673 +63477,92061,84286 +44789,86033,41416 +22275,67627,91647 +66023,72455,40811 +67636,46784,12039 +17731,14380,32856 +47482,80870,5629 +53048,17723,95975 +22510,8587,9707 +92413,34083,96541 +74356,61188,67295 +67348,10602,78760 +41322,4637,27510 +13927,44706,43906 +41185,50232,75362 +53824,19717,17383 +99533,87154,50191 +68994,18076,91206 +36155,77793,1447 +53597,75059,75372 +68503,92714,12288 +50310,38510,46169 +15899,37816,98917 +63144,94272,29763 +54237,67414,63630 +98504,43050,71073 +53245,31625,97770 +56424,45630,53839 +94990,96759,17754 +2497,84313,8833 +91822,60522,10184 +91060,24242,20855 +87896,8174,2070 +24937,99357,18171 +98497,32105,27277 +3620,27956,48885 +72626,69507,60533 +90215,64001,40467 +38991,53400,71671 +25769,25095,70188 +37741,46365,25396 +37981,59399,77043 +72720,29074,62184 +20624,61037,98046 +987,46698,39340 +78573,2693,82223 +73001,55954,95509 +46022,55133,49253 +99803,79220,81215 +75368,61106,33551 +93045,19965,7294 +90628,67470,49004 +16699,88732,18935 +10419,56226,23554 +66716,95401,72589 +45872,58167,66322 +92403,43104,64892 +13997,36471,53119 +78917,57305,57894 +79743,57189,51366 +27287,61835,89547 +39606,27416,98081 +39402,86770,32997 +30568,15022,19569 +45848,26291,30081 +99037,20748,78085 +57746,62446,50421 +9421,31159,64322 +88413,74099,40150 +69500,73567,10285 +5045,28809,37625 +3125,77960,75056 +37777,79226,73345 +65412,85185,47854 +90897,46139,2776 diff --git a/2025/08/part1.py b/2025/08/part1.py index dfbd5e9..3ce6939 100644 --- a/2025/08/part1.py +++ b/2025/08/part1.py @@ -1,4 +1,5 @@ import numpy as np +from math import prod debug = False @@ -61,6 +62,7 @@ def get_circuits(junctions, connections): """ # circuits = [[x] for x in range(len(junctions))] circuits = [list(x) for x in connections] + circuits += [[x] for x in range(len(junctions))] changed = True while changed: changed = False @@ -69,19 +71,27 @@ def get_circuits(junctions, connections): for x in circuits[i]: if x in circuits[j]: # NOTE: Elements might appear multiple times per circuit. - circuits[i] += circuits.pop[j] + circuits[i] += circuits[j] + circuits[j] = [] changed = True return circuits +def product_largest_three_circuits(junctions, num_of_connections): + X, Y, dists = distances(junctions) + connections = [] + + for i in range(num_of_connections): + x, y = X[i], Y[i] + connections.append((x, y)) + + circuits = get_circuits(junctions, connections) + lengths = [len(set(circuit)) for circuit in circuits if circuit != []] + lengths.sort() + return prod(lengths[-3:]) if __name__ == "__main__": test_junctions = load_junctions("testinput") - X, Y, dists = distances(test_junctions) - connections = [] - # unconnected = list(range(len(test_junctions))) + assert product_largest_three_circuits(test_junctions, 10) == 40 - for i in range(len(X)): - x, y = X[i], Y[i] - if not is_connected(x, connections) and not is_connected(y, connections): - connections.append((x, y)) - print(len(connections)) \ No newline at end of file + junctions = load_junctions("input") + print(product_largest_three_circuits(junctions, 1000)) \ No newline at end of file