end of day 3

This commit is contained in:
2025-12-03 23:36:36 -05:00
parent b87fb99001
commit 1b2b0f4edd
5 changed files with 260 additions and 4 deletions

View File

@@ -1,8 +1,7 @@
## Advent of Code 2025 ## Advent of Code 2025
At the suggestion of a co-worker, I'm participating in the Advent of Code for 2025, and thiss repo will have my solutions. At the suggestion of a co-worker, I'm participating in the Advent of Code for 2025, and this repo will have my solutions.
While I plan to do some of these in different languages, I'm 2 days in and so far, it's 100% JavaScript (my preferred language over the decade or so, and the one I work in the most). While I plan to do some of these in different languages, I'm 2 days in and so far, it's 100% JavaScript (my preferred language over the decade or so, and the one I work in the most).
Each day should have instructions for running it. Fopr the JS stuff, it's node 22 with no special packages. Each day should have instructions for running it. Fopr the JS stuff, it's node 22 with no special packages.

View File

@@ -8,6 +8,6 @@ It only took about 30 minutes to solve first part, but my answer involved litera
``` ```
cd js cd js
node day01a.js node day02a.js
node day01b.js node day02b.js
``` ```

200
day03/input.txt Normal file
View File

@@ -0,0 +1,200 @@
5353323523322232362334333433323333353233331313222372133133353643423323233323333534414523333432223242
6344544745655555456556556566665564538465555575558846455665837545764555554465564547547565544657585435
2246273372253242254243532252231242225522622633532222322234255122531222423531343223123232234213323424
6545643634344444495734739454433454439454355654483544243344534445434437426443854344454534654439534424
2356636643143433535443636338231745346538433576334436353176353333433532345344334224435234343644332536
3221311221443323323322222214632342232233222322333436263122265162212321261323142262212332322125216222
3336332333336335335324359336493238433441666379243536334165623214253384333323893933867663434332383763
3235321252332431332223232436222532432226223222213233432853535322314122221322352235213323124321222233
7747414497436487248442267552492479384474234455446248329744443925392334434541569266444929243494747414
2122226222322225222222322222272222212322224112522232222222312512212123225232222212222213313212132233
3224443316335562857163563325423634336554323453453433433335438236533345544244334534335993332634216343
6538221646457187823426542425322582531534227632563325754142684522242254657542156221631363152461168822
1542536242345411513432434214436444421145237442245713753325334223442344255323842522126262554447244233
2747297264129552356747857425437522662372473225142284128126274192625427252857642727263225343561622446
1222242324213122252264334421222424442242223212222123234221423124242212412222122212222232221324333421
6425743444586458555985722545674542754271646246756364246456695146433255223645247444455222364147384544
2635445333382434242243444133132564423554632446335244544424434353433534553425422443134332433263444453
1155862622241257247786865852626125378224422892455214723313212228223144236522525622422243644122572386
6779128272463821122219292323774722422519284275247622522832822926942113123228328223222222445723432282
2232251223288223136215424412542244267222173252422623243723325825722461213247252272732313242333226253
4364753235549655455345466555344444154555624455543157235254464483579452463244354627336524544355345555
3222731333312221322462262622233222943223232232262223233323323412252133332233341323122212732321336222
5211422424224332543421323724212122242422122142245224223122224254322222124224222222523224223522225242
1253468966786275819335349366292697257342298784633386548712765372538284464662759828637484539586534224
2322212222212232221222222332122341221322111322124222441121542212232222524222311122242222224814221222
2477634856718455373457466666884778784597776645446657466496247574972885325367775777777731946484436786
7474541684839334553834495443436935745646574748646437544263656556523454735943375542635168418452437445
3328853348364311836322475332345383463739875845535633312613383456374434453337647224382883538495513538
2243232332332333333313322133233323332343323243123234234321313313234343233213432333232223332343322143
3553154454325421254346264455326155464646444454454644445651362424576356553624475545825533415461154755
3372142134325331332412325324221324322255222222552432223252332355232523343533333552436312344741321432
8223352743372634371334238266323336381235733322366223731356336733643333332612123342934353625233333422
1542654246241622226422764442256512217236242532622722922584224225426423422275522281212566312241112244
2422212221222212212222332232222222214223232223321312223222212222132423222321122222222122122222233222
3224334125212444232323224422343234224454244142441321432421324544422422444244424284445341214321233534
2153325633442262447444432244454643755222342415422455312242612224242464222524353136323264242444443324
6899445495655878867445388398399859548686858876899896896748663479787988498769864998988889859778687968
3424433223331733473353444473312144334344363332323243434333323323422313334343443228332331424532445263
2421437334321222234322233323333134331223472443312322332342242432413334322532344263343223242231142364
4344392553242444982445475467442635434445345333659435833457444444544234239444423576954764816843546443
3366321224233383622221212444222734123426442323366253223432272228563436131555717222222811122349818242
5431233253232424444613434344745421344235324344433291123323334433373433141424333343333333343324237343
2523261422241223424243224224122322234222523223242422222421132423243251112224242242323422223422224432
6232222122653322355345323368424352465742634433356363253332512354233224332322236222124322272533343655
2312522221222221352211211232221222212121222224212212111222222422322322222221225222221212522212222233
1322344422222236222333132323463222324112242342342323223222213222432222262222222264233222233324846262
2226222422222241622332324222332222221222222321311121221512141291321212123221122243123133123142231221
6525663466474443744544555324553435554435334332366244634635646644635326445444424654556631434554435475
3421121434413321332232254323642623324343234123322432332244332744435641437323321334223414121323233224
6462421337173332462177535716726126327732164132457221256665714155136127533356272417766255743276624289
2431243151346433231132135256232364536627523352353732123141134432143341233343323343323321244422332313
2222222423422222242244221223323224214242315121324423222412222422221521221224224722222226522122452121
4421343212534255244522122512521452213434523425154512554315423352313242324521451534221545313134246789
5227253633573225315223232526324861327952453422372424451155242245577376225443343774522631413545364555
4434334441333236423544444644476243246337435434474444344848344546643445554444344446535543363454454433
2132212254232132322322122222311332221222222131123122223332222211221254122221112224222261222212223212
1222242153222222112322212232121122223223211124223221222217212521222227212212311222522152322224221132
2654413733643484363344347624178913455234472444646349248472443324243484423142332496334234444543448348
2223222232222221332621222251332311121322222313122212222222522323122332222221223212121122363221342223
3334423334335423163344352332431234334332243543614424332234245334343463343441243373233652432533413336
2282232122221422224113323213222322242222232222222214222223212121212123413224423144222222324431222322
4212223222232323222222123612221222241123222243224222424222223222112222224563122221222322432111222242
2222222353222142222221122722122222232221122115232121242211242252227251322225222222222231247222252252
4221336233233152233233262353126153442531363253342222433333353333533333332334122132423432353433533423
2344144377444124372644154546523355244443234424449439544434484364436453424334344714353633441333434343
2233322471514343432824629433343122343144332434273243346524244457224353743444282126345174737764236212
2323312322323242232322122232222243332231222213222123215432351142222333212242231233221223421221222151
4143334324363363766135557364236235535123542338447613451575433757955763376247326746464636333625363584
2233455543432142424342222342262531332223544321433211322113233252442233132223224425355514423542452343
3622813352774733224263322422522793345273437237639833459214744819228523793448575845773546372356843827
6645364568476457156562357558685797565776444775736547676667637456564567484473641448763545656476746557
2997262645444874284712323341445833443584989444242873424341482443223444333246448242834813448333363248
6353323433434434444384443344343324833343327453247443454333344343446134344334442643543344443134443944
3233234343414333454333225421433324346322333343334343432274334143336252224434434333445623332342234743
1322354513324255515532342613543521343323233434152242323243253214153641523342422225213525232234234341
2433133142332232342124134224232272421327432333423341232324222229422233313132132233241333225423323322
3223133723221322232923425252325223324341265222282227183222132241332162251223124234632223243546182922
1235333432633933526324325354332333132333253742632333332331433345333323424563335433632333322233323131
3533732313323432323231332343333332332133136222223338533733117333534332323122334222132322343342236221
3525543431332535334242512431243547253245272343522334443363325344332353872322334343443445463445328143
3843232333233331523324342333334462455332333223324243613233423434374343333433372433764542343453324331
2211222233221232334632245463123143332342433213223232221343643443123432334332333252363226253525333433
3542525621455343533245643444533222311412323324642554224333565452343215253312222432455222442444342123
4143321339533432352132125463255322341432423342223421223233554434342222233444223243243242121324244223
2333124433332321224435231343432233223344822233232223433351455414243433443433132243333334124333293332
7514545523745748464354546465834453354545746553375664244344432574254333844594633154145644326334734457
3994798678473643722982335379524986228856558473355726266994232287587225182793383434834433349964336473
7763477776353375426433774486644533737343464936133364434397245344234735263593947646534466324346436439
2126224323142223211132341133224241742441421623232173532321924222222223423242343221648233322122323442
2433333533443732223433323243533634432334233233513442133233332443333343413343334343314233344232342334
9451555932545454243585465654566654546644354344533438248315325466353644546444452534716444355583456563
7255424335433444324544322534423315544453425524333232424734522362424344534133412452425524336443432482
2334223332234323412222365223322414323112353324434222234224422323233322333233134411362233223232242224
6455535445544365244455364544544263365235556253566642448555445424435364587424542554455354534353445347
4435113234142333323332232432322313223322223243222242342312143112151322232224231214423422311443366334
1523422222215212522522412272222221222211265221532122165513252423221222435441232222223224212522322251
4134929732663264332224633455393133833273283973935322721238525969317535643272625137534334632328422439
4422222311431411122222322133843426222273512312423341234242223225273723442125223231412222324334423222
5444132282924224234323233424521233412222512211211153253425243324222254497253215221422242322631213412
2142224112222443217332433222222242322142312223232231534422222124143222322222112424214141334242128272
9324612132132231122322233222262422262311222211116322242122622751512422222123222326512222526322672522
3324442323323422332331343654362343224343339224384335352344333326443325343323222323323223324151983323
4332313254124242342553153453212421612222142214321225352232422322252223522643322212422323242432242421
5643354953483646563446646334666893147626435447355565365464672466624443495767665735448157538946554647
4553843833542366327571518348727477516361681223726714731567613683322158454623528216124222117538436459
7322323221421342221121242423345432522523731332321233123236332222223342224321353332221242323123222212
6555666769667347666987784776977965977365785687536755878463675368885776664347778686666868787767674658
4412423433734332373233233322211232447442122322232351544432234644322224333124422334433356424231232533
2338344373363458295422782163622384273212257222656217233916521122222645212142332123221721715671222772
7746678897865773773538357479647665467739366338783977539885477538225464646574639686777379649837472838
4433335666613555547634354354442755645425464554417425356445445556453344434335454584544456664557258346
3333332322333314333433221131343334332223243533332323222333313432313333324335443332322333134222332342
3138261272242244725128363742349377433364434532216234351114369231123333222225426532474223348631493716
2245113534224433335332324444333442232243522432322443424132224225323322334424324321334241442141432423
1323334322353445532333734322331323623322332336542523633321523342233223251434243337343355232123326533
3222222222224224214242222222422422122112222322123212222313223424222521212222321212222232223221222421
3546541333353333544566833235535244321323637735433233323355336342563353342323423234662542314733243537
3723555535957761636538683558458287623836864588847835177547827774246773639344464646674364943414245569
2312423244262331633224233221222212284242323313223434333332133223345433432123223132223332333332232333
3632224322332323623323526246272233532324333323133353254326335425324131233326382312331222116327326533
7344332451523434836324633544435553722444642344414531364433254223445353343524355443444335443433515252
3215312342321321212333323222234263323323332233325233441322221222222622433232536242225232223315117213
2322122232122222222212223122222322232222222222214221122222222222212222222223222222222231222212231221
2223243432223234222333232362332133222242313221242322223323222223323331322212223123332212322132322222
3664373674553744232533347223284337432333353337343334632323236342716353276333632232645454183413346333
8767333965692433955327637823193536734749339664924213532262654733552221932342239633498259122383478272
2253224221424223221124122222222232223243412222224322222222222221233224232223222121222123412432222322
3762263574666456414563433574624154646544365235654545452652435646336436343464265253245656664555544444
2632425474642223338324443233434334445425242433441473414552234443747424312333441334444313344324344243
3554253324439422316342321342242325325314322242125733453255242242263342431225233243562534254435654332
2122223222221342242112233221231232212133232221211233242222322632312322312212223223324321222122431322
4225226326552325255252123314555342411432423225213235223342232422224233222813332232422225522462432223
5482882527713757742933367425745325516523554227515448536292362555445233523342345382756234194765466354
4243142324332133333411323322242333324222232214223433434674254333213323232235434334543213224331436331
4433132232222416221261222233342312426214223162223212322414222433432852312432424123253142322124214623
3722656343327315555555831356854344483332355313363366623346435435265634813783683373561433323646963942
2235231213373225223323212321223222533252262233324323214334132221215335633323235623231233123231234333
3313332333233435355533382333424263332441273224373335333132223234314322242332323321331233232535333433
2324251314221222244233441222222222322321621342222322211326232554242221233322422322226222213325262422
4432563335322662335243351284532321124122232222165353414221423452422322431543222212225253212362724432
3334335335545213337253345343425345346332324332352223324333233336414453324394333561333235334336424243
3533633332212336362322222128423324433432223323323241334332132443223322214723332333214222222313224232
5333533335232723333533732271423333423533233333351323222332532526332335333343342633263433322325356443
4462522223133313822212523531222224323222222223312213222312222321222263212522242211222232123232242123
4455879445744546454555744446562544755765435663456355246554573873144393549865884444438437434545652333
3553355464439333345316443765455564341632532442454554554345755134243334532235222363455345435563353412
4429242312242337232434274244234222134422232244444412224242422324434224323322221242242222631332242433
5347558453854545333446544175335543844657446382556344345546635386353547753663265665665554636667766485
8325762535256543633768874174562379254836575852473656669428475456237259715733242536345447461865473534
3459445926929529431926337465225584663213936414743654685623472742239558565854528425526156783351946654
2322452324242272222322222421542432224224713277223735234224461222254222513171423622242114263322122424
2433212313434343214414444243142233344411433112242424244243321441331432124443412344434423123331356789
4332413543455162564563532354635546343323332343335347335542615542612236476343435343323444215235355624
2231221233222124223231132223331221222232214218242422212242233231222321223132222232331333123342323342
4413323523344436334144233434344323352522332734232324234525323245433222214514443435254329324433523371
3121222221616324251322229212548122225225522222423652122125222222571224223422362325215222242452242482
4311223132422131223333331243123443262223437433332242234333334232232133434222322433133532227435333233
5457444433566538437584354643454336277344655456233574464533634594453474664573725744796487654534744567
2292222232222433624212922222223422822242232332222224122221232122132324224531441435232343254236422221
7431845232734327612272744442693277214351636832373253621274542234226672674236322235222332461312252434
3212121221232222222227522234322222321221232122232222212222221222212222222223112422373222324223216221
3244212322331112223332321222223223213312214243322243424224112131222222312123424512212331222312222123
3334332413342844474334622243453255243244333422321274234333344232449224821341424373334732233323481315
3237262621363223232222232222652262225422262115232532221224287222322222212224462153132234232242212222
7436264334237472341813444437238275363832344334954224124534442344331433442523236367242323265224532324
3212242433333632132332314343223333636324423334473323221232335332234323322332322343235341332122333221
3372443423744734344444885433345836434427348853337443436343734343374424344674233434382433178333465834
1444211422323222221222122432322212228222322132412322222222222222211224242222222132113221223222122512
5841452433233332712433433222213443554373623423512235143221321243712432722433333332248622447423333325
2333353334242325343324353231232324354333333323343333222333633334223372333433343323223334333143333333
2412222232721222124622223371123121262422114222412222226221222231234222223842522131131122232232212222
7262573264374145654852973736342223743523814239347623662432222666615464455435353229662785251432423466
2636362423473253734445534127459242813852832341543773444246633436813569351758386368487336636339551466
3812442654456563443454443636564543235296565245725523534553644242644536631556233363384464558235415364
2212221143332232222224211222224112322222222422322121221222321321234223242122232212222221222512222322
5554556845554756569664547668663365556545544536634566788556557554665458565543775723588555555549535587
5742142353326493143122344324523524329333538524334388644333523233232243535223435394352459114432443424
3222233322132225422137212323232222312133223323332223252133232243232343432232564122323323222222311123
6322126222222274225223323545424362323132232232244257422634322233624333267232342632242246232321213363
5251225621229226286262327766573723532271382761222275332563212236642232726373246624422326632457222634
4273145373222962742244444355312124441322422351544224342342231311444524252232214423261422632453721156
2434332633122232423422231124242442621442246423322223233534324322224343243136234624722321333332413322
5225463556666552638565244323564363565636348336522425135253542932335232223456536637456343455453462335
6364556666322443247267643334666386765356643545443771246455463426247565366456224645443434353733462327
1484546463695344341124523342268248245644235267362545344425455527562353723244243456643163421745133325
2222226129242121332222311225313221221223313222132222221923213211123322121222322423222222222231322222
4345632625626633634332215652544424336333433423561333546333222532265466425554235343243774641343322436
2463375233426343266433354344332744644534744342417538336744134433364642726327341544334632344432444443
5365423724633533363332323472471273138234275242366348133334231536335332137324443452734484544644322367
5464553564144442524554224453446444554544523555446555555445546534535455464545952645555455455555445355
4324334344343333333444325323324333342322324353344384343433463333231342334633213433334332433344325336
4236383343432246445343323161432252327534233232234473443347122443433524331344343333514824243124744434
1324233332426533442322333222224336324212335434334353427312235421623232114423431233214323344314223614
3513563415321425131264424532514412136354513126543564541452226135614264315353625522421263566361445789
5534566555575463255445646566345266453245552344454553556665536756365555336347535345364425345364464375
2221233322133241226422222123113223313232222322276322226133156262134232232553613423326536223424365232
3385324644333584333243334363444224442344434344333335341534434333435344433424413334344334333433356344
3323333322233113222255622323232225232232355523433331233235333222321412344232233233123233313262233333
2643333454446544444383351341444444334563426425284333334754387444446452653732344644843444322238363334
2112212224221323212122212232121422221211292212942125222122223422322222422223522212222211332222222272

43
day03/js/day03a.js Normal file
View File

@@ -0,0 +1,43 @@
import { promises as fsp } from "node:fs";
async function asyncReadFile(filename) {
try {
const contents = await fsp.readFile(filename, "utf-8");
return contents.trim();
} catch (err) {
console.error(err);
}
}
const findHighestOutput = (bank) => {
let arr = Array.from(bank);
let highest = 0;
arr.forEach((val, idx) => {
if (arr.length === idx + 1) return;
for (let i = idx + 1; i < arr.length; i++) {
const output = `${val}${arr[i]}` * 1;
if (output > highest) highest = output;
}
});
console.log(highest);
return highest;
};
/*
const dataToParse = `987654321111111
811111111111119
234234234234278
818181911112111`;
*/
const dataToParse = await asyncReadFile("../input.txt");
const banks = dataToParse.split("\n");
let total = 0;
banks.forEach((bank) => {
total += findHighestOutput(bank);
});
console.log(`Total: ${total}`);

14
day03/notes.md Normal file
View File

@@ -0,0 +1,14 @@
## Day 3: Lobby
I had an idea for a solution to the first puzzle pretty quickly, and implemented it straightaway.
But it was also brute force - literally stepping through each possible combination until I knew which one was best. This worked fine when only finding for a match, but the twist of the second puzzle made it... _impractical_ (and don't think I didn't try).
ATM (11:30p Wed), I've got an algorithm that tries to create the highest value number by pulling out numbers in reverse numerical order, but it isn't _quite_ working. My current hope is to come at it fresh tomorrow when I also tackle puzzle 4.
### JS Solutions
```
cd js
node day03a.js
```