diff --git a/Day8/Question1/input b/Day8/Question1/input new file mode 100644 index 0000000..10ac4f6 --- /dev/null +++ b/Day8/Question1/input @@ -0,0 +1,1000 @@ +4477,78514,19310 +43191,71515,88873 +42612,67293,33896 +93418,22423,36917 +5862,47208,64604 +33150,90085,16948 +22084,83186,62997 +8857,69719,34783 +28331,76019,68949 +21341,96180,59189 +78543,86410,58145 +95058,18607,64333 +55694,53913,21667 +82293,33958,8519 +50654,45109,49699 +53736,42685,38547 +56024,84075,58792 +79719,21101,37933 +12582,8145,90170 +53133,89856,41600 +63739,70466,1647 +73792,16975,18845 +75071,12639,11023 +17434,40723,8538 +63724,13508,27762 +981,30654,17814 +4875,82413,55743 +6961,78337,92957 +50184,90841,69415 +84870,47634,25542 +79570,37088,19896 +22811,20817,27431 +59524,27179,43030 +41805,91841,13710 +53088,88702,48574 +92373,60968,5348 +56895,79800,44062 +64808,91825,33091 +27073,86250,35253 +2122,85361,92266 +42864,92012,94173 +65863,60073,82847 +34867,17502,51848 +3107,97344,50592 +28819,21548,71142 +97408,6123,11168 +26777,10815,22318 +51610,55551,28771 +56929,2742,56418 +55904,7726,83428 +49678,20860,46659 +83754,21538,322 +48251,85446,93200 +45127,40649,50232 +91239,84486,39924 +96737,20513,18715 +97682,37616,383 +75882,83625,5509 +83125,4321,84170 +1495,89473,90850 +79262,46802,49324 +38024,48414,77974 +50771,45565,98154 +69597,72543,28754 +23387,95437,94206 +65882,49611,98640 +55562,8376,19171 +61112,27660,60064 +8133,69550,88929 +49714,99461,25650 +92715,85835,8801 +47080,8868,11372 +10504,36821,9249 +23776,50153,45910 +2486,12803,45339 +29481,59995,2772 +66203,60924,86213 +90869,81470,63110 +89728,10028,42258 +79658,97191,39978 +25794,10519,2769 +58120,52787,93443 +66717,91909,37117 +21716,17216,74611 +93855,45767,89872 +48574,73613,35494 +74663,25959,67473 +56429,66096,41184 +30246,87901,10098 +86742,50721,38341 +61765,52704,89478 +71616,58260,17700 +48616,80113,37690 +6965,7554,33083 +9971,21612,86415 +2112,92003,97430 +98120,55365,34730 +4782,44440,6183 +92030,1374,55211 +63787,54389,83646 +76451,30053,7503 +1103,78344,8743 +86744,41037,81269 +86181,11900,12871 +23967,25459,77625 +54630,16532,11879 +88677,6235,9487 +44017,5384,91356 +53358,82550,64827 +81881,38851,24635 +72636,85830,71189 +43194,95457,64334 +1883,22953,96715 +98309,83166,94580 +39984,57421,23560 +48001,72449,78264 +64157,30063,3052 +5061,3936,61569 +8785,43335,25912 +56532,61427,97629 +94595,81836,34164 +20239,46797,48753 +61908,65099,3348 +96415,24687,84176 +17204,80201,54646 +2094,5241,60385 +33780,76322,5912 +45434,21337,77165 +65108,53399,92439 +75173,87618,39190 +68360,88862,44449 +96642,5044,46876 +97273,85584,81222 +44492,73807,85171 +87360,2061,93012 +17144,78534,54029 +20723,74093,80525 +42287,16194,87882 +61318,51231,72849 +68087,27649,87923 +34429,67229,26539 +76777,86066,2902 +18130,41046,41465 +2334,2536,84124 +18157,74767,88867 +51938,66407,55114 +68446,57789,80082 +69086,21235,25809 +13997,17417,39707 +65866,88933,63254 +88044,27538,17531 +82710,37374,3897 +99293,30178,85672 +16589,36487,5998 +10269,25515,23069 +48800,33085,71658 +72045,14958,45863 +96868,21771,35881 +31749,45205,5433 +44794,88313,56379 +69757,49291,58196 +21685,86360,56901 +80223,9226,42147 +77267,4507,40146 +11845,67132,58468 +36740,76915,20329 +91037,81763,39287 +53336,63808,54978 +97078,92999,50434 +15979,71951,33795 +69054,13815,55974 +20978,22295,45088 +39811,8281,91167 +88165,86261,86104 +3824,86437,74259 +31690,28974,76353 +91625,76200,73372 +83837,41258,46545 +60037,87097,19049 +29827,40987,45356 +54269,35136,37787 +66252,89090,26994 +82923,63373,35650 +64668,53111,87190 +41776,66053,85518 +84551,33194,89508 +63420,4574,76510 +84246,57911,62360 +27114,43469,46556 +50279,25848,24848 +72824,42833,81998 +2028,6972,32377 +5009,27319,59899 +5438,8135,19506 +47216,83300,21686 +18595,7112,5252 +97086,49437,19059 +91730,14032,13383 +22289,40086,87513 +37681,85465,44238 +8592,89277,69043 +96743,98978,37364 +57160,97312,54525 +88520,19193,14332 +43835,32276,15658 +98225,95637,12404 +57258,39305,90282 +71096,98413,73983 +87530,16597,31657 +36928,3289,8678 +1133,11688,53618 +86086,71967,66839 +34315,22566,47313 +60719,787,66941 +81928,26654,65657 +23057,85718,97413 +83185,58814,73824 +16816,40673,3292 +2765,6302,10902 +26823,31476,82368 +27318,82264,78699 +48459,49215,74406 +76267,42884,69113 +78053,73949,7156 +43688,29768,63463 +30468,75068,11225 +5195,23763,36494 +37680,54550,17582 +88035,79055,59454 +62713,10226,15709 +95382,31377,49611 +60069,98901,73367 +6808,29341,79655 +19272,48926,5361 +29116,48714,21237 +63995,92543,51727 +2532,48294,39149 +16137,62500,23618 +10288,22466,63075 +17337,73029,33816 +7357,65278,78132 +33848,95585,68204 +59235,7862,46590 +87151,1169,35651 +91895,60902,7192 +89912,37863,23280 +60534,19224,16135 +94896,77977,62641 +34520,62652,10816 +55781,87176,81329 +50206,71555,55458 +2474,23626,7553 +7554,75070,31442 +15430,97613,65849 +17021,33566,42601 +11363,10523,64856 +69677,62682,50739 +58045,38431,91903 +6810,38656,43320 +49239,73232,68692 +42847,43438,48663 +31273,76492,46604 +78007,64607,59410 +28293,5317,50769 +62329,11161,64034 +79124,21612,20741 +3872,96665,96698 +11305,97782,61550 +21475,75687,86238 +79648,37630,53691 +42932,13631,64875 +6894,99666,61010 +50665,19666,57844 +41458,54525,60810 +68858,68726,95585 +17903,60652,1662 +20743,19028,67714 +29168,12016,32817 +27084,91863,30066 +87521,94377,38742 +4119,49982,17151 +59731,2185,33999 +54520,88088,7827 +69571,23387,82375 +56835,16089,74731 +43003,48069,76730 +95532,98439,94009 +2529,347,80855 +57917,23869,24400 +58879,83198,27129 +80240,79052,36814 +93956,61098,99277 +392,31019,4845 +52947,70815,56255 +6900,26476,5145 +42495,43072,44625 +24214,96288,33707 +55350,94289,15821 +18832,71111,38964 +401,85452,27783 +3705,363,78458 +50792,45985,1913 +66664,95167,55071 +39714,26682,40250 +765,50681,46080 +48245,60623,6793 +50612,30177,4550 +50748,90336,33635 +5688,65361,8771 +68693,62019,21838 +95629,5094,26112 +11028,35319,3137 +56468,79591,3701 +19391,85718,85513 +98434,57261,94360 +96728,72547,1592 +37511,76791,56131 +89803,82510,2732 +22025,72626,21604 +14721,72900,12498 +53237,3183,89768 +53215,12694,46852 +96136,80861,45456 +51549,13887,32529 +80419,32323,42626 +9479,83048,85982 +5414,17401,67025 +23129,12243,4977 +65698,51634,85730 +58497,18498,11476 +28523,54570,1991 +64987,42010,83505 +27731,9586,3945 +55738,69729,40915 +97170,54258,61225 +93985,41494,23539 +84199,95402,99928 +4618,44469,90199 +13504,66028,91589 +57332,15240,9033 +75368,95722,3760 +75399,81768,71229 +35742,77862,19973 +39252,59526,42700 +32349,49555,40786 +74885,20221,52366 +76407,67388,54221 +37890,1212,4838 +9549,86220,30854 +99447,7709,89281 +65227,24411,88928 +40252,82634,21465 +98011,5066,63607 +88823,63301,82531 +92762,50776,38800 +88609,40853,57882 +76308,32095,41117 +17714,93631,75740 +53052,50413,9883 +42438,82382,54945 +66247,51011,72894 +54007,34484,72343 +48986,15057,12912 +32488,7606,68185 +5601,55291,95319 +18785,92589,9431 +66549,83446,2684 +81935,78829,24648 +54078,46995,11792 +76083,97728,91474 +90424,2280,83130 +30000,87179,29206 +22513,27219,79208 +86358,97159,3862 +49258,74129,75824 +49252,64652,85795 +80290,84912,16867 +83076,75027,12806 +93111,23730,97313 +54670,15288,34108 +9901,14819,74983 +87858,11550,22952 +15554,12234,958 +83123,33819,77793 +58648,43356,59858 +6877,99272,32796 +9344,46359,96050 +91203,19943,15158 +90383,42430,82622 +45140,56127,68888 +56948,62926,80898 +9454,33484,1091 +79940,86455,38391 +11005,53209,28056 +97852,70641,98123 +76271,20803,22846 +71067,95917,65772 +40496,55542,39814 +24970,31569,6757 +96640,49674,70197 +47219,91896,14852 +59325,39232,23627 +56849,521,44412 +63039,40917,9985 +41803,8133,20089 +83919,41797,44247 +23995,77335,37836 +89313,76103,28463 +49378,10119,36680 +85301,53403,17311 +32619,85120,86043 +35973,85941,4132 +36956,11761,31913 +49714,5635,32611 +12736,67069,47808 +7599,1102,95524 +904,58366,2329 +45716,37590,7613 +77614,270,85965 +32241,42419,29095 +61826,26936,12067 +82057,53591,64225 +75297,91405,62407 +58501,80149,12917 +40178,39299,64934 +26476,55932,10473 +80140,35647,8219 +40153,40252,73139 +47815,66747,53339 +69974,73826,70334 +81780,55090,67479 +99851,40929,57380 +65130,44282,90488 +11168,86136,21914 +82742,60481,96302 +43670,14766,97652 +35319,93841,70841 +2449,81521,456 +14406,2770,91759 +25466,94051,4735 +93365,56251,8838 +25495,32167,90094 +48293,57241,90904 +64872,91000,35627 +90056,45811,41977 +34049,4205,50346 +87913,50205,66051 +2785,95759,50000 +64022,6219,14344 +32516,52928,983 +21571,38637,8091 +23607,96935,44267 +37150,65898,67118 +20404,78772,65294 +42747,58930,29780 +91228,28957,21510 +50715,61015,88327 +74838,61365,56945 +69738,98495,91727 +85154,93326,50299 +47775,28776,23394 +21274,65284,92225 +36077,19814,96955 +841,35771,68327 +28818,27781,27651 +40430,80172,37036 +67655,91720,68446 +2821,85641,60309 +35553,38745,82098 +16722,37775,18298 +99199,97816,6607 +16516,48657,51103 +36136,52988,72872 +68704,43891,71617 +23379,92530,69894 +82749,58310,1460 +14101,99694,5293 +38987,89402,82153 +70171,36399,67583 +13234,27663,26799 +83707,70453,35342 +12833,12681,42143 +15432,43564,45320 +3059,43079,10400 +33259,12471,29015 +89205,88136,76943 +47738,25637,64385 +22146,19037,87321 +13032,13829,25489 +32904,10413,29580 +36603,81185,67708 +8531,1703,99986 +49516,46082,79338 +83962,40031,81513 +46712,2999,19271 +76250,4711,91113 +57416,54468,84186 +12668,18959,81853 +9041,4455,38740 +75653,68571,4635 +96012,54205,53117 +61951,59788,57778 +65902,80104,6394 +67597,13494,15118 +48470,55351,15739 +69997,51677,52113 +52302,46734,21762 +713,61040,35679 +99226,67975,27800 +75618,12850,38388 +7532,72436,86084 +85559,12936,52308 +68042,92074,75288 +49791,9781,77782 +5896,24342,68068 +43086,89871,44093 +96683,79714,99165 +11796,52059,71627 +77682,95845,87094 +40024,21091,66931 +30224,18493,533 +69656,30418,47149 +85064,33892,29029 +6713,41727,31494 +77812,1457,65597 +91772,45850,56992 +80975,17358,97402 +20656,51119,114 +17817,42402,81610 +53756,69530,9131 +21866,30659,68031 +99390,82508,19905 +35456,95600,41805 +72381,63540,21973 +12236,27178,58133 +86163,55212,27770 +43755,66510,46139 +92662,42103,63074 +8268,14952,55455 +85563,8467,509 +51014,83563,73986 +52403,61074,91056 +81065,77322,55945 +97520,44815,30873 +70673,19349,17807 +55982,45432,8061 +33807,79604,66025 +28989,44793,68189 +20778,25362,54064 +98760,68147,69923 +6026,77422,83688 +74837,45424,53307 +45388,90355,53203 +80625,34738,40051 +36693,82156,74200 +1643,8546,74602 +67493,6417,60239 +50,24890,26732 +15149,82728,12855 +50714,24177,77685 +82786,97531,67751 +55749,69498,36166 +33326,36841,39061 +29970,11902,27177 +35318,22231,72938 +72929,73196,2194 +39456,27572,48081 +83360,57194,58135 +37943,87222,79121 +29260,27610,45900 +23073,97138,61943 +20389,92193,88450 +61477,20378,19434 +4396,5258,14009 +35687,75285,91579 +27633,1030,47035 +38647,67010,47734 +33953,39860,91527 +87633,50691,68750 +55583,43418,94847 +58077,98456,89600 +96883,98192,32459 +83154,68616,98702 +4399,32905,50078 +92152,7031,90258 +87995,81851,3990 +39061,40131,21113 +26292,49536,27499 +76643,62867,28339 +91546,63222,27444 +14515,23295,24425 +54517,18275,34845 +79151,87032,87378 +36019,6041,35896 +83727,57276,17310 +48594,12708,47823 +95633,42301,29607 +50242,67943,71052 +43798,61593,49430 +81276,2864,88997 +60908,3488,98641 +75084,49552,57785 +36460,36557,93797 +58392,21592,35597 +60084,68445,74775 +98191,84638,25180 +6237,41891,55488 +61312,77266,65523 +66498,38427,15252 +49161,49876,69520 +35184,79917,80120 +91261,53733,50204 +89770,92014,64766 +13739,75108,63259 +13996,51312,72658 +12702,59560,15023 +185,14387,11827 +34956,19010,20505 +94401,86162,48707 +81739,76900,2986 +56345,17163,74056 +70504,26884,4250 +43320,23875,70561 +77010,10641,2026 +29032,91991,10218 +65412,41915,53592 +95689,32786,36743 +51389,6865,80321 +10870,11603,5087 +90421,6957,75344 +1940,26408,12534 +99512,38074,33677 +77716,8216,42381 +45155,77412,68141 +45166,67824,99785 +99556,93709,93072 +20994,83521,44031 +53777,97298,67660 +80718,18648,34942 +78596,57257,94822 +71295,4226,95135 +4418,48683,37594 +31433,13100,86235 +64810,45148,48450 +51728,9372,13061 +34319,21484,6267 +70603,42436,54276 +1593,63570,83668 +27302,51962,37264 +14647,16505,16281 +93060,58470,97983 +88366,53656,45136 +95362,49119,80397 +83860,63590,22440 +24860,27896,41824 +89808,25884,76621 +6091,58280,69018 +50041,31203,28847 +51981,39258,25765 +83601,74375,81673 +24522,97306,27411 +81519,19356,91885 +67354,21691,39830 +40487,40464,19780 +82731,4408,95474 +24650,58997,53759 +88439,36049,17704 +97866,2821,41638 +7679,89512,81896 +87846,5189,87947 +90352,44199,24004 +77754,84749,47777 +5019,66931,8507 +64477,74974,89793 +24238,17364,56495 +44315,25329,77062 +88671,14315,8389 +3555,83164,93440 +49836,68400,45051 +8278,82879,68265 +50321,64221,67319 +88186,8442,31216 +44006,61452,84378 +82351,61002,53815 +90835,70859,4 +26402,39529,18734 +52758,83741,6630 +20438,39064,22292 +89000,79359,94520 +68523,16671,73574 +19105,43536,25739 +35544,81556,49346 +62323,61394,41761 +28039,80490,87123 +38983,62991,58702 +68269,11010,37196 +4034,27136,53661 +29506,50308,27572 +5482,59322,14686 +55486,85074,4215 +35179,82257,71259 +90805,89286,3729 +43225,83615,29348 +5246,58548,44946 +1699,57783,33433 +65442,74440,39346 +69097,11025,24234 +95189,21769,63563 +96465,52245,96520 +55019,24075,28452 +58012,62982,89159 +12175,31513,48513 +9559,56998,42503 +13763,42671,65872 +85214,17289,9859 +94466,31656,47112 +47733,25336,68765 +36399,4600,86255 +47323,42561,90283 +62169,21091,59222 +871,80440,66505 +10950,23469,3338 +84101,95031,53584 +5486,64033,92761 +54092,32783,34726 +17312,51840,64148 +30229,96844,8738 +29643,96585,93324 +48697,74530,87933 +20677,51212,15673 +70617,74376,94694 +76490,88911,61 +7358,42035,43589 +75778,46479,74384 +78292,33510,15936 +18732,56194,5676 +61067,5640,77534 +14566,64974,78733 +38302,72714,53561 +8697,51368,83895 +91830,73268,47937 +13932,91520,13569 +92187,82280,22196 +14728,82684,36340 +22767,93630,76606 +45431,98357,19312 +67496,58311,85018 +98162,23165,32098 +261,52791,61220 +70188,25575,31787 +7656,18019,94271 +49679,65694,7481 +67145,59132,73065 +20009,53987,58597 +65889,44536,91982 +90892,4850,36855 +85073,64778,77303 +71776,80610,50907 +29059,6660,51791 +54433,27733,15362 +33766,32963,30785 +83893,46772,15074 +54501,94597,26524 +30737,83446,33673 +67514,10925,55407 +89431,92166,64630 +25650,25603,63232 +33196,91868,8077 +9986,35182,21654 +85057,93852,1254 +6119,3085,76002 +4360,93924,25856 +99364,82626,80856 +83128,68492,43216 +21813,45032,12129 +7304,39324,7305 +81248,87232,59116 +7777,57427,74919 +56579,28932,86674 +9132,35052,88597 +78187,92197,28598 +76638,8066,53021 +32416,24840,21940 +25886,73447,40652 +66182,9180,78674 +32045,84567,16326 +88242,52082,34758 +57849,98397,82283 +69494,22159,85041 +95201,68687,80989 +97760,46658,12880 +85626,17905,74715 +15871,82069,21640 +67558,38110,31042 +92687,19894,84262 +71086,97189,97006 +87641,70826,67646 +25859,48394,92577 +67308,6377,1528 +22828,89214,95100 +83142,6549,24018 +33648,59341,69103 +41965,40777,10817 +90418,31166,38374 +88587,56701,16491 +56373,91865,2048 +20905,41652,69780 +39565,89253,52510 +24406,94016,59023 +38650,36031,87311 +64426,11004,43207 +97530,484,84630 +73288,41416,49323 +8714,24934,702 +98409,71884,76287 +82288,22208,19294 +13155,30395,87305 +4147,9640,73985 +9467,34396,41915 +15324,54218,64963 +9658,81258,1899 +41791,63508,12721 +88628,77500,48905 +8675,77225,86536 +24676,80656,35596 +84057,21723,75674 +22584,5649,95478 +98075,51548,54215 +63696,53602,5843 +68879,97380,44574 +50260,94231,96543 +89236,46476,33211 +47407,29337,93481 +14747,26041,43873 +82194,39994,1839 +52677,59848,75775 +58090,77879,28825 +98145,6047,23699 +67347,5760,31791 +33012,18528,94977 +34951,55138,77756 +67150,89991,18334 +13443,91817,92433 +68956,84601,65387 +76379,43251,24336 +56166,90851,57708 +2351,10362,39968 +94877,39645,67846 +63185,72034,71467 +94369,6017,67421 +53255,68564,21924 +27191,5940,45717 +40526,52093,40819 +41892,82530,93969 +31241,72973,64618 +19627,82535,51410 +30331,4304,24723 +98382,48075,43338 +29102,6829,12760 +52387,52134,78816 +71250,11596,93430 +23328,7381,84014 +31940,3364,83353 +54473,71540,56585 +50161,31743,87740 +25471,39491,88326 +57467,41424,8205 +71573,68318,34573 +68883,64217,19069 +24707,97197,12289 +91295,44290,71210 +68908,38796,34171 +794,67980,94694 +50749,48491,11235 +7654,52089,14841 +2474,58941,75436 +59667,24375,24743 +54474,43315,14751 +2565,25854,22830 +80138,90860,27290 +79126,14945,9950 +49917,53247,94994 +37907,45158,25689 +89989,70730,58911 +18634,26130,21234 +55191,38152,98581 +85522,99296,8787 +77526,63631,66332 +5741,90130,83119 +57897,31132,51802 +42308,2891,65294 +64273,78823,73710 +12621,5847,41733 +45849,41522,67249 +94355,92265,11580 +78851,1824,44117 +24737,689,29765 +13425,50177,13953 +63899,4458,76976 +24713,57732,11901 +20156,96828,12010 +77593,17128,28465 +25059,12275,70489 +70222,12195,6218 +34756,14736,6214 +88617,91143,48919 +97710,60000,78910 +23791,87306,32172 +71742,30944,79703 +14664,29777,35239 +1296,10941,50365 +26418,82108,39875 +38391,39631,11626 +94522,26185,98292 +73076,39755,76742 +39404,37561,39758 +86531,48998,77616 +48161,55091,86623 +85223,3967,32041 +324,47943,38695 +74543,85862,6772 +67008,16080,76286 +58178,43173,75814 +88514,94853,46108 +50027,57890,74732 +29809,71270,58492 +20194,71859,27485 +6223,90299,72368 +85408,78124,51981 +96459,54321,79044 +98958,24934,65860 +87332,10596,99385 +98114,77613,89042 +13687,78288,58658 +469,52704,27130 +8955,15556,71189 +83406,3997,90727 +71154,7181,20888 +14307,10971,49108 +92862,99608,74996 +50495,64890,88293 +51888,98840,79918 +97424,74935,10638 +78392,46400,98376 +1334,57833,55713 +94153,24621,8647 +40255,99225,76754 +94191,74188,64512 +12566,62081,82396 +13565,68565,77628 +91730,18003,34234 +34639,32090,14006 +18724,81675,17427 +91164,79204,69735 +16509,73776,75384 +98000,72172,14442 +17219,56884,1181 +44688,49584,65200 +78768,67320,61144 +93546,51605,84373 +98040,38328,69721 +10348,86911,2406 +78563,95626,11944 +9011,26253,79703 +20485,89760,45732 +54019,91005,84612 +24396,44804,96933 +4683,9342,35743 +37165,62534,59842 +21670,43593,83890 +81845,69397,25281 +24961,40438,55604 +89771,67401,28961 +98835,18640,93652 +8707,57603,29446 +51448,25444,58612 +76175,70004,96152 +96398,22643,96984 +55264,1603,5190 +47778,70364,73555 +83015,42720,24750 +72777,46787,7239 +12526,49927,22569 +10943,71279,74252 +11863,68675,59946 +11829,56611,46461 +73655,82081,6735 +7260,21652,21966 +56221,61784,68637 +41466,82984,82221 +73931,84481,31653 +3940,61477,68330 +97987,47061,15859 +17108,90894,94390 +43507,95127,15709 +53798,72652,96883 +95928,86611,29205 +99814,20141,36437 +57079,25230,1056 +46587,68897,80446 diff --git a/Day8/Question1/inputTest b/Day8/Question1/inputTest new file mode 100644 index 0000000..e98a3b6 --- /dev/null +++ b/Day8/Question1/inputTest @@ -0,0 +1,20 @@ +162,817,812 +57,618,57 +906,360,560 +592,479,940 +352,342,300 +466,668,158 +542,29,236 +431,825,988 +739,650,466 +52,470,668 +216,146,977 +819,987,18 +117,168,530 +805,96,715 +346,949,466 +970,615,88 +941,993,340 +862,61,35 +984,92,344 +425,690,689 diff --git a/Day8/Question1/main.cpp b/Day8/Question1/main.cpp new file mode 100644 index 0000000..8dd75f8 --- /dev/null +++ b/Day8/Question1/main.cpp @@ -0,0 +1,154 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +constexpr std::size_t STEP_COUNT = 1000; +constexpr std::size_t TOP_N_COUNT = 3; + +// Just for clean code sake, This is doable without structs or classes +typedef double Distance; +struct Junction; + +struct Cluster { + std::vector members{}; +}; + +struct Junction { + int64_t x, y, z; + Cluster *parentCluster = nullptr; +}; + +Distance distanceBetween(Junction first, Junction second) { + return std::sqrt(std::pow(second.x - first.x, 2) + + std::pow(second.y - first.y, 2) + + std::pow(second.z - first.z, 2)); +} + +int main() { + std::fstream input("input"); + std::string currentLine = ""; + std::vector junctionList{}; + std::list clusterList{}; + std::multimap> + junctionDistanceMap{}; + uint64_t junctionListSize = 0; + + // I do think we could process text and do the necessary calculations for the + // solution, but once again, code should be preferably legiable + while (std::getline(input, currentLine, '\n')) { + uint16_t positionOfFirstComma, positionOfSecondComma; + positionOfFirstComma = currentLine.find(','); + positionOfSecondComma = currentLine.find(',', positionOfFirstComma + 1); + + int64_t x, y, z; + x = std::stoll(currentLine.substr(0, positionOfFirstComma)); + y = std::stoll( + currentLine.substr(positionOfFirstComma + 1, + positionOfSecondComma - positionOfFirstComma)); + z = std::stoll(currentLine.substr(positionOfSecondComma + 1)); + + junctionList.push_back({x, y, z}); + } + + // This is O(n²), ouch. It can be estimated with T_n, So idk maybe O(T_n) + uint64_t count = 0; + junctionListSize = junctionList.size(); + for (Junction &junction : junctionList) { + for (uint64_t index = ++count; index < junctionListSize; index++) { + junctionDistanceMap.insert( + {distanceBetween(junction, junctionList[index]), + {&junction, &junctionList[index]}}); + } + } + + // Ordered by smallest to largest key + count = std::min(STEP_COUNT, junctionDistanceMap.size()); + for (const auto &Key : junctionDistanceMap) { + if (count == 0) { + break; + } + count--; + + Junction *first = Key.second.first, *second = Key.second.second; + Cluster *firstCluster = first->parentCluster, + *secondCluster = second->parentCluster; + // 4 real possibilities + bool firstHasACluster = firstCluster != nullptr, + secondHasACluster = secondCluster != nullptr; + + // Both have clusters, merge clusters + if (firstHasACluster && secondHasACluster) { + // Since both are already connected + if (firstCluster == secondCluster) { + continue; + } + + // This bad boy merges the clusters and updates the pointers + firstCluster->members.insert(firstCluster->members.end(), + secondCluster->members.begin(), + secondCluster->members.end()); + + for (Junction *clusterJunction : secondCluster->members) { + clusterJunction->parentCluster = firstCluster; + } + + // Temp fix + secondCluster->members.clear(); + second->parentCluster = firstCluster; + + continue; + } + + // Both don't have clusters, pair up + if (!firstHasACluster && !secondHasACluster) { + clusterList.push_back({{first, second}}); + // Directly writing, can't use the variable here + first->parentCluster = &clusterList.back(); + second->parentCluster = &clusterList.back(); + continue; + } + + // Only first doesn't have it, append to second + if (!firstHasACluster) { + first->parentCluster = secondCluster; + secondCluster->members.push_back(first); + continue; + } + + // Only second doesn't have it, append to first + if (!secondHasACluster) { + second->parentCluster = firstCluster; + firstCluster->members.push_back(second); + continue; + } + } + + // Multiset is preferable + std::multiset> clusterSize{}; + for (const Cluster &cluster : clusterList) { + uint64_t size = cluster.members.size(); + if (size == 0) { + continue; + } + clusterSize.insert(size); + } + + // I'm so tired of this question + auto iterator = clusterSize.begin(); + uint64_t password = *iterator; + for (uint16_t index = 0; index < TOP_N_COUNT - 1; index++) { + iterator++; + password *= *iterator; + } + std::cout << password << "\n"; +}