Advent of Code solutions
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

aoc day 3

Rain 31fad2c1 d9004061

+307
+7
2025/rust/3/Cargo.lock
··· 1 + # This file is automatically @generated by Cargo. 2 + # It is not intended for manual editing. 3 + version = 4 4 + 5 + [[package]] 6 + name = "day3" 7 + version = "0.1.0"
+6
2025/rust/3/Cargo.toml
··· 1 + [package] 2 + name = "day3" 3 + version = "0.1.0" 4 + edition = "2024" 5 + 6 + [dependencies]
+200
2025/rust/3/input.txt
··· 1 + 3465793544554539453556366463344563446545344434374421565553674754454364545353445746344674866324626454 2 + 5245519416772346223526354314328255235753314533349425533231263525232272412553451431424512533492434633 3 + 2323322222622242333342233232235654332273233736622333323428122236431322752232333222323322273723224333 4 + 1225213326242322232212132222222321425122331122112255265222222121221526223422423425122233123222221212 5 + 4242212334524244436421494224465443243224434456244522212434385243222434423642226222516446522642152253 6 + 2232939252252513212222222265225322265564434312664293123522432122262244262623631922727278656241128723 7 + 1442163245413423443433323444243222414433441334344343135154445122433232424441232441323223434332233442 8 + 6433215372332433633313333433333223523634263352344644632333532422332372533532335333332199342333233341 9 + 3567366666636726574553542144373545521474247931628685351338363327746637433272661177242733856754264235 10 + 2442436623324232261364445231242421233527222321233322445344622414623546212422342214282243222222343522 11 + 3544455525356348342232423332243433444345445345534136345343333753534933142353443323336251434353334442 12 + 3433642721442432262322833122223434443244241444432243124524242421124462323442541343442214444122249324 13 + 4243325225315342314242333412525522272222531215225267372342324482562443422481624235364442141724253274 14 + 4474464443544624434441333233443333253351353344362324124328424434343233444244142533234323136464446244 15 + 2424444322424424222433533333233235233432162334342163132213322439354231312243321924333134534325354241 16 + 3232221122422323221322323313233331332363432242132322233121332123333422313334323213732332732133333233 17 + 3222322222232331122221251221232223213222222212221122223233122222232822221223124222211323232222222221 18 + 6232236123236274753929682613566443243253962523753262765352435673223257225642452554444532443363323595 19 + 4412342126432222432345422442325222422234222142222122225123231222212314274212231251222422244222244242 20 + 3334233232222332233323332332332622322332373833243321323323222323234322511233253213332242233233325122 21 + 4545449647484335323236345664334646244625754252459655453246465155543444591856358341433354253543284898 22 + 4251156725544565574225422267416322115546226554282626222561547322683566622441345343242645482315272716 23 + 4336516735675464127522224272374276546755445467336553212142552226752573366735447515437271661365253673 24 + 2334336222342423323211434232322323553447123612325221332322124121324312323223523234322433235422764233 25 + 6356422371522626425432343132523242522142333442214222383214222452336142531435645224122554323433334355 26 + 4524486583649549244886537237444474456934654926679759646659485579659847684384794243796215423978898299 27 + 3225372242323322342452363233124225727614424414223233524332273232662143234123321417232431312617434224 28 + 3124321345813322314332324333332522253426333222222453284332233341231133413333336331232223236333723243 29 + 2225244425584242224652222243412152112543262432123244222226322221212252322223234251855222244132222225 30 + 4355244313434534632644363643432213353451322474222334634345634375434653432343452747323393634537533335 31 + 6514313463553536352275944323242525534843732912244262445153572943625282221722333288125343373431222332 32 + 3343554565349537736455453546656575634455155484575248456545555554414583434556355545348446464446933535 33 + 3213424244458273255422124343533613323322229266432712224126641612321132423537123368221923233263282315 34 + 2232213421312223252353324412331612412225231322122322152413535253324263532423245222233322222442231242 35 + 5443233324254333533434324434434333144323434443333231944553243433443243432323343433244432332243334434 36 + 3524243871148545235444445273423145535444232355184544353454552244433341443221535453453344134524154454 37 + 5425161533425154523216289222424183112215851216721223352243332147725353422223155625521522331414454254 38 + 2234523343378343332362342363542632434325423353635434457333334423445452456327243433432544432242341333 39 + 2323233232323231232512132233223313622231223326233354342232322243223113333143232223223223262342241224 40 + 6522322629553522223969122272561362422554217318332421222442242137321223965915934354624657244276541722 41 + 3333311432333324323335132334323333323333364323252233135233241243331333333334337146333333332232223521 42 + 3555356554255545565657555525455455555555564655547575745564563555645555467356755555444655565565565544 43 + 3831522412242231212224762421512424342212446124766237343463527242426832369425426437226768513212425352 44 + 2133124122312232132265222222353322123322232122326233223332226324312226127232342325213342452252215242 45 + 5274575432132542567521443155643572277433436613244646316732333522756313424244617232165513723661757589 46 + 2226223622332612238212327258215222523722342212318245752512231222228223122851222321255322662222221222 47 + 4224622243242232349125331363215223314242264252422323234424312164422234345433224425331441322334223324 48 + 4544354454533443425424334344344434334435345344364454434444455555534536434445544452334434865434445654 49 + 2332325334232433233222337422323272122332342332232233142242323333331331636232372333373123322422333133 50 + 3542322526235222224113323212325424223222221533262122222342221252118121222422325443322323132262513222 51 + 9657886667486798774777586787668587844464848644447847775666485556578882658777757465387987776878763656 52 + 2233411332122342342322342333211346422313342233222512222222252221222223223342132332321125152323124233 53 + 4746743746523327126433763465433463366171375375552472334363263331247243163731133365356637337432636232 54 + 1412551432243422278352333241242412467234447233416246433443592442324364641227233221242542123672226226 55 + 3331333328337335473333332133343343133535117371435433173333324217356323334638373333233337233233332452 56 + 6443264744631722824212663123544344333212842292452633633355843632243273633591374642123322442352242236 57 + 4422124221232413121452232221322222312221424222432222243222421233224441312422531221422222542122421113 58 + 3435666451466621681263426568365665465235676645767536275646753543644144223555526235222665256625454447 59 + 2922213213234225462222536323221217221224212322222512312322132222511222228322332313312222222222253333 60 + 2235323332533322242222213332332334223244322224332223334322435324641242136247233323246553221234212424 61 + 8262631625132245262236245221722223322225222237241352213122222222223121422421273223273232222231322622 62 + 2231212322241212223422222122122233222712322242222222122222221212222212322122314724222222242322215212 63 + 5945222343332333733963232233533643235243213222333343178543244323823223242342433333333327432333341332 64 + 4444344343345344152243344344436434333344343444234233454244443344344244443441427441344223344442313414 65 + 2223333213522332242225733222223323314343413213322314332337225222322232512343632412213242322234335313 66 + 1254263324241422126232632532134334422524811115614262124242262254433243221423224414593562283434335621 67 + 2333222222422322224331411132322322332223232124225123222333221421122162263245334423823219722213322342 68 + 2434332242432428343444434324445434233332514324322544462433431444224434233334454454242442223423442334 69 + 3342283482236633355223252425314422524383253333333345334212324255253232332325456335152244422334344535 70 + 6222361324242222223422422222212222122321122411222236122222122222223222222212213223231122232111322222 71 + 2233224268582212434352213252283252123225224232222552518422532822526222244432223222322527324219551142 72 + 2332352325334312133343743223335334253226432312333583623222523513433943352333252235713763436213223323 73 + 2523333224122223262222334322522212212524222424421321132253222214242211453133144213254225123422433542 74 + 2221242333222221324232242331443241252323323232232134222322242322332312332332243222426322222223212322 75 + 2232319262243333333333242323233353333283233332333323333334313333433333332332732223331323433523113242 76 + 3748495746784273535647695854993667554946368858527212597754444448579777158929932994514449735256558596 77 + 3243342322283323234344433434333333323323936374331313273334334442333333373223334434413322445123314433 78 + 2392212515825453523222535555125456225343456317425524223243225342252114224512322352244322447222722621 79 + 1422222221242231122222421222323222222224232222222322211223222342332223222312222222212241222221222122 80 + 5532447126435166121361454412545626153696237122222355862323436443276325267438633135424477633626734663 81 + 3251333324133511311323331221623323324349212322233822222524322333323353232322452322233344335323323333 82 + 2311434441414442211431241413342114324444211442113414141232222341411442321114441343213223214432156789 83 + 4332134322344443435232332444334344145445333422232234242333323132332312322232533234344123332312433334 84 + 5422765282352246636454261633463262243222353734423465265361441513464355133233436145563323322322662225 85 + 5454444324342422244444471323444243644444284244458334134364234244123344442222444254364272444535243444 86 + 7674687373443555655726483445345555486393414455556438395257447551766624654574539532443524555655453526 87 + 1323353324335433432537335225321312324443325335334323433263343341534474375456341333333594333455456744 88 + 5684367658694567566738555646559855886696656654657755567897467944975677356676464895766855472769995985 89 + 4543387367835676457368786544574268743342332339333874575375457548337654744346553743713754774638347533 90 + 3232633354234432525332433434223263345343221322324464624432343535534221232654123552333338352522365541 91 + 3534593478347466436755467544343985355545486515744284447647753922249635752748379384664736446813346577 92 + 4447453333273646234332323544535444444747443444556447544443452543345442337153543761333342353344246354 93 + 1544354224224245135324322231243223215253852222333532333452211235222241355431312245224333226433343435 94 + 5446475385594438936737895335363677332476635664265365775743734583865554687666786254355797566535955635 95 + 3344653222344242234524534516333522254134223855455545553522533222254332553314255535255355234333325445 96 + 3732333636535537257445565346334646638433465236233455533363354465634357533375245733454334656356346463 97 + 1126232323822823731522324223331223331223382426222234223262232223323212316333832224232322223253222241 98 + 1153269479352238642633362487126622416426522255731463456541236414213512725652265466221251661222675732 99 + 6444132743342135664337232814723365551333545343223225326455452896663542754323261323423215621543241926 100 + 2222436247225422212123422112121322125252335212252244324242143222712222342225443254222122255213225425 101 + 8345658533743337373354634763464156114536255466668377556964665344376343764646525464535354275426565346 102 + 3343447354444331333347544332334434473323843452434553433322345433424524344143334483335449422326344344 103 + 1213333247323335324432222233423353233333133331411332223242523333233552333355253333333335225333533533 104 + 2338462726774272237123333122226748232232577175529776855525542252572227256832542467146615217222365223 105 + 3353543335333232353353553233353447533433435333565353343343332545534133335635843453523535353365521345 106 + 3554333436343345333542344233355333373333431623434434433333334733224339414327633334463433324383433354 107 + 3422562524292651232225133522373133442522322216122235524233242415233427252712222762242132224322423232 108 + 3333343443233324323263335243333466442334813323622124332464322237622432354314323331432223343372443223 109 + 1344443454333444465423433544444434536451444343444424344444134564444843444443544144342554333446424336 110 + 2512521225122926322228218223282222232225112212331723322222112232213262229132121622222222392312233212 111 + 3746422767464552665465366545254453725637381577471457237837464625323629716156735544554444763955573123 112 + 5573742652355133487761862446745655534875446745374674455333387444454635556776253774694443443654435573 113 + 3124342343323223423443234431221324723712412342326241312333422432243242373492664535444348233324423323 114 + 3233235224212222124321221212242333332322237213333232225223143322222323233172422272322223242242313225 115 + 4263453331345333224365423423562625533144324134235323332353233135232343212233343572215533324223523242 116 + 1212221222222222122212222322222323431512213222222522222242221122211322222221222123221223211252222223 117 + 7855475354324624544333423451462552456442434363545417775565355437565354877755554536556653335545554935 118 + 1222125322233722242222315237228322421223222421325242232232122122341121222282416322241422223221124223 119 + 4447243222232333342233145222324542322422332121224432322433334243332232244425331323342473234233245142 120 + 2534354343544246457354555465444477746734134354544465443544475726775544445652133434355546445344464644 121 + 5332283443353251333543434234143333253332255332323332423253332322513533315233631332423323223254334561 122 + 4433333333346433344323343824323721324343444163334365631342334433333532353843232535543334292333247333 123 + 5564656466176645536336656266376225575523455364576647764646755574655666696444565666665666656665532765 124 + 2333552422217533254433222434466535332453251252323835325342334441345261323442458353334233322525532513 125 + 2342125541144143234253414525535252413214243355354121322114445525334234341312323133113412145521326789 126 + 1423232411732422912223122262325232212322232222225343314326213431316623222222221332425233231312323552 127 + 6646573356262182646258283774275762626225746524246644842226268466728662464226222652818237211162223356 128 + 2272822619616222421212222262144177223643222326252527224261172612224326224112213636214122121166245246 129 + 3333423434294444233323333347333333332249334332335414317454423456372433333711545244332232331334443324 130 + 3222222522121322232313232222232352224321122333233223222252222221222342312123222322232262322223422332 131 + 6323131211234233224622324323233313233325732333253222135123225322222331322252335422232322224223452222 132 + 2423212112322522212226122232234442212212916132224321312252344222512112133217232252322288132442215212 133 + 2322331343313623223232123242372231213333722233132312131325222333332532325334342352432223123332322525 134 + 2453144724432327454455343414416365565446434732742443545372365552215532634545654635264747432556522331 135 + 1224211222125222222243252254252312226224322431422228142222221416427422281222222223385422233442616372 136 + 3334454544454552647445644564434446442644554544365543434435356444434646334235443445455534644331644234 137 + 2332222221222241221231222222212212422222222222122222222223222322222222321122213322221222222312223222 138 + 1334332323314331474322123332632213332242332332223433333342323232323424423322323323232322323333326133 139 + 6463654474322633334673656524174345444343633374187441635334423434333454443449454534634233533738423334 140 + 2222222222212222322422243222422322234222212462262414216242221123222222222112822232223122422232242122 141 + 3748434553357224364356536557573573528444277375555645866237635546232325566633357424566786658852632434 142 + 4444637538444445465723444555644445464446464445445636815453456333443755443744446744344573447444464474 143 + 6222542453645124426126665245342613634342113614246564241525324342642252556364656433651113445514311789 144 + 2322224526214323233232323235332433222314345222344142224244221214244233343445233221233222232633323332 145 + 2422332424175734324227324273427356427212775354574251243641862421473544664322422734324762264465846485 146 + 2554452341322422323225212342322342345322524225525523223342245333424312545434452226236255215345132224 147 + 3876546623336684235632556653533336364853433433535513333362144343444454866683353433563763344563435334 148 + 3435354874847333445347352455445445136444444347467633344432323446324235425712335422433454665354544444 149 + 2635273866873872727372392154242261222426271221347862327542422822442433726243436375524476722853636592 150 + 3443456444214445565444124644534534524444352344244424344443464444253437672265534541332343422444522131 151 + 1231222363375332233265422223277263153133482323313322426643322323332333713261724132262353927234323323 152 + 1736444453564382744736533734732325422944731332333186826597636444485423334543225374439646445443542756 153 + 8421334433233245242346633324642532432542223224122324726422246338322484324334322232266244933226844232 154 + 8623631635636762112134334155462354253227565543242533873653142952526214412265546464273827446553255652 155 + 2331229731722243172242224634212333292224423121246334226724126322135523623672322222422224322775414221 156 + 3223122352333122133222312221211242422233222222123323222222332323432232132323231322233212211253222122 157 + 1338223334333433825523323522335633424326235531753323342232214243327241156332533828431243632333641133 158 + 2222222223231322222221222522214212222121222122422223224412222213223422222232212324222112242222224153 159 + 4113222724212135243324522222322224324122512242221121257222323264323422212215242132212322242242213232 160 + 3323933133333333333333232633332232344332233333531233328332262333241211323432234323343333422433233322 161 + 5333382332428381334334233327334113223322243352332133432323532313343272317434332117228424213132332834 162 + 1331332333433515232323522433123335322222123341632533323152123243324393523225262213322234223225233332 163 + 7244423122434642743443223413634414233343332344232221333241234222222315253222352332433121736422337331 164 + 3133435262242342514253123511342142423237222425333212444263422522122232222233232522165224432342322462 165 + 2323213223725122223332422222215311321322522522334223511322122223235225222331212322223222223131222223 166 + 5657744884755524544486851477554644457284575425788243654655558334566627274566558884588546778553845453 167 + 2224212222231233713225122212222121122322222222322222313454322421238112232522521221322222285323212212 168 + 6699276416567969254939613966462477664825126576467968789634658662915896178776644669647991355835236258 169 + 4225223256124443214232221724212122125221222233212212222223441221222222123113234222221545212172222222 170 + 3222224122322342223321241622235342233143633114442322223331343242234241234532264421452443523122122233 171 + 1327633223323313234532233236233234133134212252135332423313232253243533641431222333133542455223372222 172 + 4432373435325445122332532332522326432222152534243562247531236522232325346114423225413212634263232594 173 + 4432146447564564564654646843445845653444256654246453366255476545445534532564944325551456546655454553 174 + 4333232411322433324333337333232114372321122215321343325422433333423332332223311333332333322713734613 175 + 2212224421343484234232132228432244412163235243344245232372231282213333325324232222132222522324322532 176 + 5434454444542453344354344424446542264554543444434474455363664425445465444445473312656443463344452534 177 + 3226333232252244313244432553132514222142424213312154212654452422142422332425124442511221233244575355 178 + 3552326357533544123215632554163246353546444853363632241742424435645324595343433939433752353343563654 179 + 1222222761212222221222221212311222222343421222322121241222123222222222322221222122321222222213232221 180 + 2223212121432422222214232342324223413522345129431242222221321521224223464322223343324343222243232132 181 + 6663773989617677875997484666966338535358664462985963389949827954674737894634935684658898846465556759 182 + 2212322424522424322211224242222153121232222225222125122222212222212312124242426332222212322228912211 183 + 3948454444864444443444633644484331466337342773444745424443535542524573945324552541438446435544445492 184 + 7423624223122444683423633341588878254673626278566633383828437541498756116412293225753567359434497228 185 + 6864435456455586263256444658466658564472455264546466465666744468845624543364653656745755376636565664 186 + 5237633365231224325231423223382542243255232242534322559135123435222534638454532653236262245622252666 187 + 1232524134222341424333413225242225723425242214222252132425442335246243131325343524412432522243634143 188 + 9848855548583588553677453875555666886554538563554476186482648553697754455743488447764554588545445566 189 + 2133221211223622223174212726231172322224222323222823351242122222342242324232422431222322425121226221 190 + 3233331333332323333364373523213322234322333332333233353323323323333724733343232433462422333337433243 191 + 2312232122212122222232121522112342313222322321353431112221232322225225332421221325332212223522153222 192 + 4453343215354352551564735344453643654412665555446542422534345633235435645346355423543856534255214533 193 + 1112454564246343452372442241325242232444624441352474256442233324423582461724345441243425444337434434 194 + 4244131251234222424312492324452323333353725534624123322532462223232436323255351432226425654362323342 195 + 2231232222313313122212233133212233322533232123222113222333212232331333223321223223322222224323224222 196 + 1735322445345322342343232224224232424343424832222443514424411232423215434322332422312345444443342444 197 + 1432212314222222222232222644225444225453424165242343242323633254321538264421584324522272422293635423 198 + 2686366345466688423546678557655413855654664663646466576547666666695368498495642644318545535757354688 199 + 7253255271222245116264224262312334252846434226552823612631167265622765821322372433825651223242182531 200 + 6176285753884783858721476418667873518844575217257773535117642812171646162823338383814863224888357559
+94
2025/rust/3/src/main.rs
··· 1 + // this is stupid 2 + fn max_number(size: usize, mut input: Vec<u8>) -> usize { 3 + let mut idx = 0; 4 + let mut changes = false; 5 + 6 + while input.len() != size { 7 + if input.get(idx).unwrap() < input.get(idx + 1).unwrap() { 8 + changes = true; 9 + input.remove(idx); 10 + idx = 0; 11 + } else { 12 + idx += 1; 13 + } 14 + 15 + if idx == input.len() - 1 { 16 + if !changes { 17 + input = input.get(0..size).unwrap().to_vec(); 18 + } 19 + idx = 0; 20 + changes = false; 21 + } 22 + } 23 + 24 + // maybe theres a better way to do this i dont care 25 + input 26 + .iter() 27 + .map(u8::to_string) 28 + .collect::<Vec<String>>() 29 + .join("") 30 + .parse::<usize>() 31 + .unwrap() 32 + } 33 + 34 + fn part1(banks: Vec<Vec<u8>>) -> usize { 35 + let mut counter = 0; 36 + 37 + for bank in banks { 38 + counter += max_number(2, bank); 39 + } 40 + 41 + counter 42 + } 43 + 44 + fn part2(banks: Vec<Vec<u8>>) -> usize { 45 + let mut counter = 0; 46 + 47 + for bank in banks { 48 + counter += max_number(12, bank); 49 + } 50 + 51 + counter 52 + } 53 + 54 + fn main() { 55 + let file_contents = include_str!("../input.txt"); 56 + let banks: Vec<Vec<u8>> = file_contents 57 + .trim_end() 58 + .lines() 59 + .map(|s| { 60 + s.chars() 61 + .map(|c| c.to_digit(10).unwrap() as u8) 62 + .collect::<Vec<u8>>() 63 + }) 64 + .collect(); 65 + 66 + println!("Part 1 Results: {}", part1(banks.clone())); 67 + println!("Part 2 Results: {}", part2(banks)); 68 + } 69 + 70 + mod tests { 71 + #[test] 72 + fn part1() { 73 + let banks = vec![ 74 + vec![9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 1, 1, 1, 1, 1], 75 + vec![8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9], 76 + vec![2, 3, 4, 2, 3, 4, 2, 3, 4, 2, 3, 4, 2, 7, 8], 77 + vec![8, 1, 8, 1, 8, 1, 9, 1, 1, 1, 1, 2, 1, 1, 1], 78 + ]; 79 + 80 + assert_eq!(super::part1(banks), 357); 81 + } 82 + 83 + #[test] 84 + fn part2() { 85 + let banks = vec![ 86 + vec![9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 1, 1, 1, 1, 1], 87 + vec![8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9], 88 + vec![2, 3, 4, 2, 3, 4, 2, 3, 4, 2, 3, 4, 2, 7, 8], 89 + vec![8, 1, 8, 1, 8, 1, 9, 1, 1, 1, 1, 2, 1, 1, 1], 90 + ]; 91 + 92 + assert_eq!(super::part2(banks), 3121910778619); 93 + } 94 + }