Advent of code 2025 (not proud)
0
fork

Configure Feed

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

day 3 solutions

+264
day_3/3

This is a binary file and will not be displayed.

+60
day_3/3.c
··· 1 + #include <stddef.h> 2 + #include <stdio.h> 3 + #include <stdlib.h> 4 + int main(int argc, char* argv[]) { 5 + FILE* f = NULL; 6 + size_t size = 0; 7 + char* line = NULL; 8 + ssize_t nread = 0; 9 + 10 + unsigned long long bat_sum = 0; 11 + 12 + f = fopen(argv[1], "r"); 13 + 14 + while ((nread = getline(&line, &size, f)) != -1) { 15 + unsigned long long bat_n = 0; 16 + int number_of_batteris = 12; 17 + int b_i = 0; 18 + int a_i_1 = 0; 19 + int a_i = -1; 20 + int b = 0; 21 + printf("line: %s",line); 22 + // go through each line (we can keep as chars) get the largest number, get its index, 23 + // go through second loop starting from that index, get the largest number there. 24 + // i love loops within loops 25 + 26 + 27 + //generalizing for n amount of battteris 28 + 29 + for (int n = number_of_batteris; n>0; n--) { 30 + a_i_1 = a_i; 31 + a_i = 0; 32 + int a = 0; 33 + for (int i = a_i_1+1; i< nread-1-n+1; i++) { // we dont need line end char i think., and we cant choose the last one since then there will be no place for the second battery 34 + if (a < line[i] - '0') { 35 + a_i = i; 36 + a = line[i] - '0'; 37 + } 38 + } 39 + bat_n = bat_n*10; 40 + bat_n += a; 41 + } 42 + 43 + 44 + 45 + 46 + 47 + 48 + printf("digits :(%llu)\n\n",bat_n); 49 + 50 + bat_sum += bat_n; 51 + } 52 + 53 + 54 + printf("bat summ: %llu\n",bat_sum); 55 + 56 + 57 + free(f); 58 + free(line); 59 + return 0; 60 + }
+200
day_3/input.txt
··· 1 + 2213322222223222132231233322432224423222226232323522232215252332221122222231232224232722131522422232 2 + 9869755494885236452767647548826258555668838497687557968652485746757835445145546687436356799481798587 3 + 1333642233323333373233223535543332333343733333323333333333315334333323343343333333332321233332333333 4 + 2412331232332223332211413223433332213222252142221323322122212223222321231322513323122332321233233222 5 + 7233333554333634354333355353442655334523373532334435335733343124433353732333236335456441345343535443 6 + 2542623755573343945454412366525442424744334132133146357442166333737542732631343535567546644733453327 7 + 3223423125721322245221313311333222222222322321672232321322215121332232323522331112523842131211222231 8 + 1341524443834221222553325236443534253327533543493534348242333119334424249244524325448544522322512344 9 + 2122222234421423322222232231221455261322312321232223321232322112233222233223322222121221322232225222 10 + 2172228252452422574523272252246532513514251543422251252233622213162235313243341322723224223472223342 11 + 4333333322374312333333442252233332323343236421333332132232233523333223643444244332233333333314343374 12 + 5564564445425635543326425252871657266475435535644335444428545455444345414454654413464444444543452332 13 + 7454483454246843436686564547347643444463364743844643844454433455547944454424656442455444258453453949 14 + 3545239364734434356884585159793673287754643667512332857278643456465359873642643268698837552366444279 15 + 2222614212122412212232521222222222322162224122212255224652222252322242352254132522221123221222222222 16 + 4654734524468553536655551947342343744798353537531365525555255373383337465222438553556563343546674795 17 + 4223343232434234223443433132443232333433233241333323334444234334443434435341513522333132223342423334 18 + 2434743225152133244934233332223333342332742413225323434322133133342225263461325222442331344323333621 19 + 4363333625436326121432327152115232112437232426739557622735333213153454854223553223332333163322332262 20 + 3291224524551531661124222122232433443332372352223452323152254212524224475353217335338132112225138382 21 + 2532334224334412444233531343333232434672372334424223232433234233235242243334444434532142565432224543 22 + 6575467444354636644724356545439443727633232211663455734655446347433346552413539455535454456546344467 23 + 2212123522212256112142223212223223926221423333322111142121322246521222623231121222222233122682282232 24 + 2427422153354454221223483334425221233131444333342323144413423342141422222343422242225233412322852334 25 + 2223222262222351122221222542222356232422221312224223222121224242221142612223533222222326212112222231 26 + 1122221221423121122222221122242426222322222218222222222122222424232223133224227122232222225212322431 27 + 2223225222263221223122232222231322132249422122222222212343223233221231112333321122224822122212112221 28 + 2234133242122472222333323231152222313322242231321234122233314332232125212342222222141222224223222243 29 + 3222421121132228332482223722323212227931233222232311122728212342422323911121332241322122212225222224 30 + 3342221445144453253254314734532247546356242543223144334535244724343441632342442234353332554531544544 31 + 6644254436227552262158566262526533915631231552333722416565536354544652263755643341664563253253335325 32 + 2212221212221266252415512232524121224221462212225225525255242115212235231241252544312222525112533222 33 + 1212222242222222122121231123212212232222221112225222122222212212222222222322221222222333222222232121 34 + 8437515934322544325244332733235426312213422543233274311523432242324234425333225643164333335325158723 35 + 4955559385766953565255766876476558356667683243721462495465455956585541549636358359356553352726754357 36 + 2321212231311222332231233622451222223233632131325333155422313242233246235373323463222222233151352225 37 + 5554455544442245353244364445444442964455743554423443344234626245334485444521454444353644544434348444 38 + 3584546435435438362463553335553744339333343334752434593543434442333333333374362737434422835322244974 39 + 2224322223132222332322223422213222223821212223222243223232222232232222362222323122422922222223222321 40 + 7532213233323334215212222423122123222322425222323732234174212342242222239222238232423135916233324313 41 + 4725333553331231732334534535433413336333334433335633862233333333343434333253574633253313333533322533 42 + 2222122222233222222212322321212122221322122123122322232112231321222234222233122122113113222142221222 43 + 7618667762444757529352444283355721866946122758937266864545275866446765437263255944277544354266743555 44 + 8775885395735793768798676737467545866325994734656888365669834844567693699478564767598836687838775796 45 + 2323222163231422333232265212225222433552125522231421223232222242111255222111234232222234643453222212 46 + 3212222223211242222322222423924221333231242222215221222222222412222332242222342226222112342222222423 47 + 2312517442152222775232225322152322134642256726212312232253122631232442222322774322261522237322225221 48 + 1412232232122132322214222245123232224232423122523323323512434322222122322223232324512223213223221225 49 + 4624745444557739264643334474753442344576454464364444542355443444953574753765466446534445555247546645 50 + 4444445543553433353354455144453453542444435444454565454246452554274346433345434464454144453534444454 51 + 5222221211223232461222322221422324122212222121524122122224222221222226222282222211433212232262313272 52 + 4443424217342232322234144234322244432422332123432122562423442343241152444222734444343343324245233331 53 + 4625363444334325314433134332342626273324257534444232232533221335211222233354622142319633834554323252 54 + 6411222232214222222522522212115422324312321212512352222222222521221222222422213215222323222542332225 55 + 4443435744444443443454344444553646453444473243634337443343333445443444444444544642353434424344143344 56 + 4222322212142222131123232424122212623122325223232222122222324172123313113213221112221214131212326232 57 + 3628228272226822792212222291522222262281252222222122523312222224388323226222431232246223822272242222 58 + 6452232522272722232314236322514222212124422122363122133442752472323254631272561324232244232223412433 59 + 2232232212252263221723231243261132732225353342123222262123232223621135231232353226314132222321322523 60 + 2234532142534352552432224445238325213424373452334233522333242532331322332283352427475226322153223244 61 + 9472212243122222252422922222363422333321126243222123963224222212173222233224252234412121222122821213 62 + 8687898777877956884675896696763989727598788596888366975787785653266667396852928885385879777658746578 63 + 4742438327346661542272567435214432666247432532364464374423432252594887642242783264284248334549366538 64 + 2843543444552553332333549456453152452655123452245534625343434434394353525145545815233325253353558525 65 + 3244334344333322333336326524543522543353334524333542335243334463433424253344265152434334435422433433 66 + 5123213122132653223552342918633223322124141221532722222222633832112321232362321212223224311252232323 67 + 2254522224536212312521242224331285151323234522312332222153222222233213252422324212324255413222233635 68 + 6932637327758743246546437713551343621222422345652667325366263533277364672223242653614462113113621452 69 + 2664332353263783333136373783525676334732434213262462433235335292339233763346833362333754633332336332 70 + 1223222424223252223213121222322322216422412224222612422223221222312122222125212222415122232226422521 71 + 3542584332435333333233354353545344224553534123354453332523352334552335453523343512333213234387634133 72 + 6477957673773844477447976677777779677788757572445797735766653875666759654537677675353627655576767927 73 + 2122863223233922223222231121222335332223122512323122233223421212114232222322232221223392322222521322 74 + 4312524534123246451432343643224311242447241134644264223443332245433262232641376442432172472222642235 75 + 2275325124326274246343242342674425241126422624221639763313155173323211554216434553212654542522244512 76 + 1538376354635334634345152866523443431672342341845227336436433755352916223414454255126676464326465453 77 + 2462132262212214732224191166344355414456333232523325425323262172634333344212243223136153134622523124 78 + 2631319623233673572328447522142326723725312315363222557334327382237347133534333342445538226351733877 79 + 6674525765645736755277426478666374433478565771746335482576661384446336527753576379765114777324835247 80 + 1445214354534443124443143152322124342543358432243223532332224344453244325421233463452464443336435444 81 + 3723543344762463142452771243123333533262534743357433433442333434323237223413433322343122246434425297 82 + 2522212232142222322222221222222123222513232222522212222241212423221222221232222422123182421222222352 83 + 4649425575652455655345524446535555664456453353551334555552535554525353745544253454663345473375355545 84 + 2634673446446644485645555244654443495523355587664334545525752374784735443457755455456485493456463553 85 + 2242233312853232212222233154124241433323223342432114322372333333333232333133312323424253242333222527 86 + 2252222222122622131222221211221252222222262122342222322122323222252212223225224113322222213227122112 87 + 7145153421321212213232213242421325372523143232242542622222334162232643213463222315224332241623233632 88 + 3324124233321322222222324392322321322222222224223432342142234421321364212212331212326242323313313333 89 + 2472266245644522634774327358522262635513323335182372254462662143946277975225436422277562365266655423 90 + 3454443243442454643335544534416344433344445654442214445434214514463442433444324544444345444345543344 91 + 4367979552245565165576424776225962637573364823785465568368636312742298786276647827575676469244525653 92 + 3225626443313133323723323323333314253554364347343365333323333336333733232322233333323433327322332332 93 + 2573343343233434433434335363345452556353493431488327365413335557454378339752343364644435453325754543 94 + 3332172133227223334324253377332133233323223333532233333322112735223232322223234272123323333632212223 95 + 3454534475343444535444424745434444444344455444623375454534443434344544444438232474343544535454434444 96 + 2644342235344483342633422636454456365233515643444645826444442446956214445156322264445433443453544256 97 + 2223435334423434443323343432344434441333333333334433523433332124432343243433314444324423343343444233 98 + 3212252222442321323221225293213122528329522211182223418222232142225234221221222222423222321246232122 99 + 4353432493542334325235547332734383332234542144323893258347384435444429271453353353448434142247423122 100 + 8337935245577558348845559668464454534353766484438335543755757443777274244484345834388345496944455467 101 + 3443463333334453433232243443222334133233433234432324222432323533323324433242132332332124242343233322 102 + 1435542554154543564533441335544555244531645445572234345443345431434433534143565444437433564233354423 103 + 3333312334342233331223233234233423333333333222332233423337233233333323213132222322314332323333244443 104 + 3144453439443334333662444343463453336433435352354493435346436453383544432444466337453337853423233436 105 + 2621273163344422333343232136211636224222434231116342222542232213433324642324241176224342723221422332 106 + 3233236263233353563335231233252323223521334126123623332512327322312223333223215221283522467362232326 107 + 2232223222222222223224222222222221221211221222123322422321223212222221322222212221222221222222342222 108 + 4443435431454234435334436543423453441422434424434246438432132274643321323342524533232532212314424334 109 + 3434222234424123524222452333431221233121324331412242454221434433122432415442443243322313221343241245 110 + 2321552222525121432422322331221528511324222222222223251323221222325322125252122222212222223233125422 111 + 2113322212122312221212122222122232221222332422312233422223123112132122232232231222235122334122222212 112 + 3732434222332433314434542433334343433225344323314343343423334323322433232435323333324234332413313341 113 + 2243352221342443222271236434365322934422234223125222337624122643272322622437441322243413243473882412 114 + 2527574826427351353683632227267232139241272336778354926836323453363482545233625417243233594635373371 115 + 2352124323843333323253365635322233542433122438331432234333233233552321434213213222343343494522232371 116 + 1322321231222372222321132512312222322322224462222223322222222221223222233121722212522142211233221233 117 + 5444455244355434653244514353733425555432435524445462355644544453443433445226446336553853553454444444 118 + 3332233333334338391321272312134322233863322333432334333383232342334223332333234786233333432424325933 119 + 1423223524424321433522322244232223331233231333313336222333934223422133232353433212332232224322322433 120 + 3846414434329535333324434434463744365584534935533343538345434362733943434244645366346976364533243345 121 + 4643437654442357354452643453433595563365355434644545556753685648354446745633345454324745655324554344 122 + 2131424213433334334241312123344324133131413343442431244222441243341422141411322341334123242221356789 123 + 7416322321423422532433252263461535237341336423224758925417544133763249354532465584557477436637134868 124 + 3532232342543633244356234447125413363324323324222289345334243223343344349423623323132345434545334456 125 + 2222222223122224523322222414412221222312521311252212471135216121622212122422823223224222252322223322 126 + 6844572852724766364376246428458471423425425655656355452483274422366737555436524246373644225524226684 127 + 3242324353115355355323223333323433133532332325223553622433333532532333223134223363333333733357422553 128 + 3626353353644274241533142456273326314323662575363324353232556433624425644535422316323346623244545532 129 + 2724454534154225253459433524763422545426423332642224232423242219414234215362382511227546231223755232 130 + 7442133222243344231433423324322522433233342443244242433423242443424324213224132442463664334134342334 131 + 3463633243546333375266535312435244564434333724665664625374363683533955743535443448446155363433352435 132 + 2264222222213232253131424222232214292212282234282122225323422451223621252222122222122222532326531252 133 + 7615864866564643665565345652664464866686665436644563376466655765566766633576745646454764727756626448 134 + 3232682631537442445212595232662334363343227323835122465351345356353233643332543416323346345346643365 135 + 2477354147362541612246656262342473335717542264534245221467537422444573332674431531423425215312544289 136 + 2334432533153324242344341754352431132342242483614364474473434824424423481248441342313143738143793223 137 + 2453444254242142424354527214334534514423135772455224332544144347235744422234224425443544453243344614 138 + 5212223252122422331232123222142312233422245334462222222225244224221242232221512243232224234433555222 139 + 4663361654535434444435333426543336213653424435533654435334427263236324336542736224533733545413433239 140 + 3363338333145338474323437333462332324223453341452444327323423238343353864322373218432131334133331333 141 + 6252146332321485753632148626252215423622661447732432532425663473353884553422633662223652246821433466 142 + 6323212434222112525725474243264325545472241252227222635137276274422143227243432646722261633476517122 143 + 2292128532222284521512222622221222422421324224222681233623522223223262427233231272222123235231221181 144 + 4286246955215254312515631624225942342242521826335223234535339245216232525515324431229213242425522424 145 + 2622122232123521122122322223322225522212213235316222222233213212622122172232222411222222312122211732 146 + 2392322272325242232246227222232731732621613276422282332227135645532724216422152724335327741242231462 147 + 2133344331342334353334326416233445424328334428226343632383533126256345224276253624433232223322429335 148 + 1313445155233335142345133432424315243344534322414122115152312323134555232124514425531444334531116789 149 + 2176422423121432443422442232123322224224142721224212222312511322231432233234223323244211222332222122 150 + 1323212331222132233231423322222222214333233212344223434312442222492221354321222342223332373533322621 151 + 4664434362444745561444535453345435524434346435454274864444654324476633565349444454455353443364156363 152 + 1638584275546117346163717254773527552852888544638242767347444874466266733617618166164466374362765419 153 + 6484454656734464566656446354242553953738747675494353263545534655932284732414565465456217445446466422 154 + 3485414422321524833475231333422824247332244623522414142222262253355414452434234344554242224422224624 155 + 2333263233433521134582215333224332925436375333333336732316531375333522444212233753383365335354643243 156 + 2322132222223221323111333232222233332322122232221312232253222222232322332431323222322231242312325223 157 + 5335322444334334442443232426223323234447129221322222234335221422223321222322222324423233342232233364 158 + 2233232223252234233222422323332233122122213133422132233223243122322122142422223322242222332521212211 159 + 2243222246232222212215234223244341293823233413422262122231434142334224211122243244723212111327343722 160 + 3313433324333323233333323332233423333523353312313633334213233333425232634123313333625322322224342122 161 + 2223221221321122424222323113232211222413233225122222222312222222225361224122154344233232252313223232 162 + 6426445154869355363363722336455335472343572534323456253645532493615956527636643453556642545246266326 163 + 4342252241221222341214232232226432422223222214311224253224847131242221312222431142152243223533228364 164 + 3122222221312333212221331241133322212322122433312122322332322212332222212322222142232224224432241333 165 + 4758777554587868737644678898656677787655757385768789874455858856835848887478458889776575587488744887 166 + 2222222322222222132444434221222223222211212222421221422124222221223422331422622421122212232221222222 167 + 5543453232434923234235323433433652346343532235133533353325643323414321344433315332531344244423332533 168 + 1422222221222222212122311222212124122222322232222122112222222222122221212242222322212222211512242221 169 + 5624318328343613762342133122287362233222333228233526432235723228212317225232222321322843831822233343 170 + 4745555462555745374333447645563565846565658565674475358542453455774373535925543556456253364455655565 171 + 2231323341221332332231232222211222122232242312343424133212222221221623132213242312314213213122222113 172 + 2342415122621132242242322221225542255222222222112241222232223222323213522222122246221231225232243224 173 + 6223131445352273462225532517237771421222422217426141752312626563272261233221417286234434252324661125 174 + 5222222212212422212223223322211422113212222441222322222222432222222222222222132132522224131242222451 175 + 3422323526233255413253234422122625354565276426242722342264341342322432242227231221345261423232251243 176 + 4455444352444254693544224343146552455424553454457554355354334375444452434455453544443455535455225454 177 + 6695865665676765678566666576961755966654564567555567567556642646397966556665359666465757356556757769 178 + 8357544347353366537753222233513443263326227543433534321424453266343553435425423918643343433235261323 179 + 2222222222222221222113122221132222411225322222222222222441122332222222232132115232313221145522221221 180 + 2224124212242232553331122222231252712234224682324732533127244253223113212252422561212242222267412142 181 + 2155131243437642435225242233334327262528545127324323242251223242215932221342512431224563331215223232 182 + 3233233821422242243223423226322333331221244225322333614732324322164332232342254245324342223324333333 183 + 5323233433722283363642223343334264332334256668558433344333335344774523223633116853423338533332265733 184 + 6636218835567665856535755855763526554865876567668671763558535573733875754666654864563576447378687647 185 + 3242212222532222453222221222221414445243225223253221212124423422213112225222222212136322222122223223 186 + 3246242324335263534434465364444433354444733144444444634444442415237463482176214523646425165642842254 187 + 2222122121452242222112223321223211222122412432421222323122222422224234323112221412442225322222244223 188 + 5555533353644375536354623527576345645257454546563754453235344566547743535526353443675773695567647537 189 + 3333334233422333245534448312255264263533563132333625233423334335232332233333924442432512333355242243 190 + 5335324246344212334344347222166443335324633214664133136352235644245321635434234446546333352834514533 191 + 3232232233742222122234123363441422152241262422235221425422492124252122242244323222152522222164124334 192 + 3462333528242224232212331221524224225335332337777262223233218633225162762134332832833282226832233352 193 + 2632332326122221121112263242232222122432223221342223342224123122112324132321112262322121522112113221 194 + 2643223122321323333222122131322331333331122234423732236222323333323223232221311311224272231332243223 195 + 1222223121241124122212232223223222122522221122332123122232231322212311251223333222513332338312123112 196 + 2152323434738233433164425517324546331332242235424332433322422413432633344543243344744343237342432312 197 + 4131322231422253332322233423433322322232222122431221333113333223333234213123233223231323332233334323 198 + 2463363425242612416264341654545345115236122326652335252424331225332623114245461624526144136446312789 199 + 5832235534333334323334233312133213343133323333875344483233343683364244333343536273324539333242273393 200 + 5336252424463368242344342182144524854253313325351235445322225455244424225253125634815634443442624924
+4
day_3/mini.txt
··· 1 + 987654321111111 2 + 811111111111119 3 + 234234234234278 4 + 818181911112111