From 95e4af9eb3fa2a45164b0039d347fbcd0fbe74be Mon Sep 17 00:00:00 2001 From: Eric Wagoner Date: Mon, 1 Dec 2025 10:21:03 -0500 Subject: [PATCH] Initialize repo for 2025 --- 01/code.js | 91 +--- 01/input.txt | 1000 ---------------------------------------- 01/sample.txt | 4 - 01/sample2.txt | 7 - 02/code.js | 72 +-- 02/input.txt | 100 ---- 02/sample.txt | 5 - 03/code.js | 55 +-- 03/input.txt | 140 ------ 03/sample.txt | 10 - README.md | 4 +- day-template/code.js | 4 +- day-template/input.txt | 514 --------------------- 13 files changed, 25 insertions(+), 1981 deletions(-) diff --git a/01/code.js b/01/code.js index a855cf3..83a61e0 100644 --- a/01/code.js +++ b/01/code.js @@ -1,102 +1,27 @@ -const fs = require('fs'); +import { readFileSync } from 'node:fs'; -// const inputArray = fs.readFileSync('sample.txt').toString().split("\n"); -let inputArray = fs.readFileSync('input.txt').toString().split("\n"); -let allInts = []; -let sum = 0; +const inputArray = readFileSync('sample.txt').toString().split("\n"); +// const inputArray = fs.readFileSync('input.txt').toString().split("\n"); // Part One for (i in inputArray) { - const forwards = inputArray[i]; - const backwards = inputArray[i].split("").reverse().join(""); - let firstInt; - let lastInt; - for (j in forwards) { - if (parseInt(forwards[j])) { - firstInt = parseInt(forwards[j]); - break; - } - } - for (j in backwards) { - if (parseInt(backwards[j])) { - lastInt = parseInt(backwards[j]); - break; - } - } - allInts.push(parseInt(`${firstInt}${lastInt}`)); + const contents = inputArray[i].split(" "); + } -sum = allInts.reduce((a, b) => a + b, 0); - -console.log(sum); +console.log(); // Part Two -// inputArray = fs.readFileSync('sample2.txt').toString().split("\n"); -allInts = []; - for (i in inputArray) { - let forwards = inputArray[i]; - let needsParsed = true; - while (needsParsed) { - for (j in forwards) { - if (forwards[j] === "o" && forwards.substring(j,parseInt(parseInt(j)+parseInt(3))) === "one") { - forwards = forwards.substring(0, j) + "1" + forwards.substring(parseInt(parseInt(j)+parseInt(1))); - break; - } else if (forwards[j] === "t" && forwards.substring(j,parseInt(parseInt(j)+parseInt(3))) === "two") { - forwards = forwards.substring(0, j) + "2" + forwards.substring(parseInt(parseInt(j)+parseInt(1))); - break; - } else if (forwards[j] === "t" && forwards.substring(j,parseInt(parseInt(j)+parseInt(5))) === "three") { - forwards = forwards.substring(0, j) + "3" + forwards.substring(parseInt(parseInt(j)+parseInt(1))); - break; - } else if (forwards[j] === "f" && forwards.substring(j,parseInt(parseInt(j)+parseInt(4))) === "four") { - forwards = forwards.substring(0, j) + "4" + forwards.substring(parseInt(parseInt(j)+parseInt(1))); - break; - } else if (forwards[j] === "f" && forwards.substring(j,parseInt(parseInt(j)+parseInt(4))) === "five") { - forwards = forwards.substring(0, j) + "5" + forwards.substring(parseInt(parseInt(j)+parseInt(1))); - break; - } else if (forwards[j] === "s" && forwards.substring(j,parseInt(parseInt(j)+parseInt(3))) === "six") { - forwards = forwards.substring(0, j) + "6" + forwards.substring(parseInt(parseInt(j)+parseInt(1))); - break; - } else if (forwards[j] === "s" && forwards.substring(j,parseInt(parseInt(j)+parseInt(5))) === "seven") { - forwards = forwards.substring(0, j) + "7" + forwards.substring(parseInt(parseInt(j)+parseInt(1))); - break; - } else if (forwards[j] === "e" && forwards.substring(j,parseInt(parseInt(j)+parseInt(5))) === "eight") { - forwards = forwards.substring(0, j) + "8" + forwards.substring(parseInt(parseInt(j)+parseInt(1))); - break; - } else if (forwards[j] === "n" && forwards.substring(j,parseInt(parseInt(j)+parseInt(4))) === "nine") { - forwards = forwards.substring(0, j) + "9" + forwards.substring(parseInt(parseInt(j)+parseInt(1))); - break; - } else if (parseInt(j) === forwards.length - 1) { - needsParsed = false; - } - } - } + const contents = inputArray[i].split(" "); - backwards = forwards.split("").reverse().join(""); - - let firstInt; - let lastInt; - for (j in forwards) { - if (parseInt(forwards[j])) { - firstInt = parseInt(forwards[j]); - break; - } - } - for (j in backwards) { - if (parseInt(backwards[j])) { - lastInt = parseInt(backwards[j]); - break; - } - } - allInts.push(parseInt(`${firstInt}${lastInt}`)); } -sum = allInts.reduce((a, b) => a + b, 0); -console.log(sum); +console.log(); // functions diff --git a/01/input.txt b/01/input.txt index 8331a14..e69de29 100644 --- a/01/input.txt +++ b/01/input.txt @@ -1,1000 +0,0 @@ -gsjgklneight6zqfz -7one718onegfqtdbtxfcmd -xvtfhkm8c9 -914two8 -vxzzvdhfqfsix83c1ttvbbstxgdrkfcnmm3 -76mkvhmbkpm -8sixssmlzlhrnineggmrvg6 -threeninedtr7219 -two2geight -3nine9fivetwo9twohxhc8 -llbfmnzzntdcfbslcl3xxvz -two3leighttvpkfmjhhonefour -1b9four -fivefdlqonesj2six -hfptgztwosix8 -fourkcxqfgxbsvjj3472 -xhzs7rdphtxhtwo -eightthree51 -3nmronemlqzfxgonepkh -9vnxqtjjrsg -533fivesixrvqfxjrdhl -bkrljtkjb42fqnp -4mrh734 -threefourfive83l -lcjftnpqfourfivesixtwof3 -sevennineh7two3 -onecgrmb74ctxhg -kmvtdrxvrfivethree2 -seven98mflv -tmoneightzstdjqjncnkpkknzoneonethreefive7 -fourzsqjbffmxf6lsqdttjfive1nine -ccs3onesgmmrb -kflkpscthreehjjgckfrfdhc3krgntwofour -7five2134 -pnfbrjhgprdsvzjrklrclmlgkk69four4 -cheightwofourxt2 -1167threetfqstpkc -6dsk2bhqmonejggkpvffhgnrbsix -five9threefour -one3136four -vvncdsg6jnxlbsb3 -fgftp5 -xxscpztpxteightv4mprlzmdhxtxmpvgfour -g4 -eightmbqbrxjbdx5 -8nineeighttwo6lcsvmvxdqbgpdbtjnnine -jkj86threeskgpnl3four -rtmpn5cbtthreefgxnhhvlkxcbtknnine -7dpn6cqstqrv7sbgzxhgrqrgn -3fivetxgjgndz1 -tfmkd8three2 -rcl55cvnfour9twofive -dmgdbkfjvsnpctj69four5 -xjlrvznbgl78eight -dmhkvgbc6four6eightwofkk -zlhzn898scffour -bdeighttxntvnslbf1nine59 -htjltzmzeight5foureightdvv -45fourl2 -seventhree39fivesixtwokchzgc -fxtbgsxch1lmdsldthreefour8rkxjz9 -five3five8 -threefvfcxnfgskqjdjknrgkvnkl6 -8jzdkxm -plttwo2fourseven99zthrklvcvp -gxjfdnzrcj2847eightnine -2onetwoxdc -35zlpzpvfn77 -nxppmskvrd1one89eightfive -glhp52f -mpptktkhrbbcsdheighteightqkjgckvxs6fourseven -1ninelspvpm -threefqn551 -eight95lhxrtwoh2hbnd -jlbclhxp72fivektxfxbtwonetxl -one7nflzdbdjchbbqqmn -fivesbgsrvzrhz2ncbkhsbrgnpbkgcsrln1zksfqkcxpf -1ftfour22hvdcqrseven -sevenjgrkpbxxnnv1nine6hzkrzzfl -fourthreefour98sevenbthreesix -sixgrrjkl3gdzz86onejpjlbpnthree -vhx3tnzcjvgg -six3one4sixeighttwosbkqdjfhfroneights -669eighteight32seven -jdpzkdnngc6bvqvtxtxfivesixthreedndsqmv -9eight6ssxcdt6fivedsnine -nine3onetjmdqpktwo -ninejjzrklhptsdzbt6tmxnpbrm -eightsevensixtxvxlqtdjfivebnvpdhvfsqbbssfkplzmkvvxh7 -xmeightone5cjgn1nhjsthree5 -xncbclzqqgskthree14bptlrknkmpntxmnf -sevenfour8 -34 -5ccslrvbfive -sixsixlqf72 -kknmskkfivezcmjrgfgclgrz1 -gqxtmrsqxfour12vlonefive -four8594kxsc -364 -hrbfxdpfivesevenjcjdm3nine9sixsh -mml5five -btcqdx7jjsix -4558seven4mjzsix -1mfckqcfk -4pjtbd18ghnnjqmjm6cvcdgjlcrmxpnnts -eight6hd -cdjdhpjccncpmrfour9qxlqfivenxjfssftnq -5bchcbpjxnsbkxgbqgbr -sixlhnzzmkbfourhzp58onetwoseven -kfgkqfivek3br -fnklssmgnine4eight -rbbnjvgpkgbs65sevenmeightsevennine -8ninenzgpldnfgjjmbqpmqvgqcthree5seven2 -seven6pdrgrldhtldhmndbjpj -5three4zmjpslhh -threesixsix45 -szxnvzrkseven2tctf -xqzpninesixseven5dndlqd7 -three6ghhzcvpkfivervsgplxq -eighttwoeightlfntmxptgk2pngplvr39 -33ninenine4fivejseven6 -fivehxbmjvxxrzrqr29npqhhlsjr2ttmnl -slmltqplzl73dxkxrpgn -lxg4371three -tjxsmjnthreefive5fivemshrhhj -5eighttwo -sixbpqtcrjzmveighteightjzgktzss1 -1qxjz57sixzh -4djpqz54122 -threeclg1ng7kgprvd -3143threenine71 -kcxmcthreesixeight23 -4zhvn4five -lmxfone47fbdsixjgl -kzcdzp2 -27twozjbtr -gpvkqdpbpzthreeone5 -bqvneightseven8qll -seven8brjrp272none -3kxhglddkjklkl -5sevennine52nine -3fourgznkfpfsxzsnmoneqsixtsm -twothreemkz6ttrtbj8 -qoneight28fourninempvltzrtzgvfdcdlxv -rllmkpvgqnkdgdrseven2five3 -7eight89fourlkfourfivejkqgffz -four6xr -6sixfive2hhzdkskxnine3nine -two6qmmkhb9eight -cqfxnmrlnhcsdqqxkn2nsncgvdxgmnineeight -7sixsdsfour4mrxeight -44threetcmtzmxzgjonesixnine8seven -dlonethreejh6bgxxmlkdseightwokp -four3lspkhhtsmone -89hjtnrrpvfzjdkzp -xc4sixvzpccdblczvleight7 -2twotwogzqhp9vnbp -rxsplmvb1two8pdtnxtbthreefiveeight -bsfdmnnj8eight -rntszdckhhcmqn21ljzqbhn -nineeight8 -1fhmnzzlfjpdp3ptj8threejqvmstbtp -267 -hkknsfivecrhthvbhhqj1 -six6xcqpnj9fivezcqbrfour4 -8one2gfsgg -mszrrqmr4nine9 -5fournine43three -5one9hvvrthreethreef3 -ninetwo6twofivefivennhjqkhzntkqptfxvdj -9onetwo5fiveeightnine8 -nineseventslmmgnsjbdgsb2sixlmvxpdg6 -8nineonethreehghh -jd1kr -drrsxljl4 -fqhfjdxdlsgjgkhcpjkqpgzjgchsixrvzqn7 -7one2qsnxhfqkseven6 -1vhljtwo1oneightqm -gl3 -two2eight1threethree -64nine -qglkhnfffsnine2three566three -7sixtwo6trbbklgjteighttwo -nkccpeight4sevensevenone -eight9ldkvgqhq3 -ttkqpxpzrxph1zfzhbvbgvn -46lqxxgrmvsix -twosixcqsmjsthree8pqthmd -ninesixdsns66lvnkhrq3 -seven413crqjpkfqleightlgxgck -onesxztkrtxksqklpqcmrlpjlnst6ftwo -jzb1oneightqqr -ninexrmlglbdlfqm4twolnlq -4seven4eightzds -fourngdzkklkxtsix8 -cggtwonebtkxtwothree16seven -three59threesix -3qfglrfcr4nine -9seveneighttwofoureightvvhpgmpnftwo -seven2sixvsmxv86 -mgvqr5two -lggjffzt2six7vxflh23 -hctpninesevenoneonevr3 -7threeqzgzm532mn5 -vltdnjhxgl6rjbmcb79s69eight -snkbpcgclpbflxbz6nkktqqgplm11bdnvpfour -75dllnlkthree93onedflbbmlvmd -sixthree94frdpkdccqkxv5 -hdpsvxl2bszdpgspqgxrzz3 -hztwonethreeeightzjqk8fivepvgrpsrxxsbfqfv -kfmh6sixv74two -one9three5 -lcn2hls3three66gsfmzvlx -tmlhhl72nhhkppscc -eightsevenprzgonethree7nine1 -1rngfnx78196sixrjbbkzp -6seven2182six -fpsl5xbdnjbzonethreezcfqmqonefive -5cxhrqzsfz34xdkvtxblkhvstcmjc -seven36ccqzfmmlvsevennine -5nrvq2nine2 -fljzxvninetqxjjcrsvp7 -1ninetwosevenvdtn4qcxnblgx2two -dcfxp2onefourfive -6czxzpsc -threeone1grvz8pvzvzkdzjfsix -hmbpnqntczjhdlsjonedr9prxvkt6one9 -dccns9threeninexgflfjltmvlssrhkbvktcfourg -sevenhbflnmglrn4rtseventwo55 -threehddkrvsp11 -6threegtk5five -29m5 -nine3threesixsevennineddgchfiveeightwovqq -2jtgvrldnbpfncfxtq -eighttwo6vtgkvpqzthree -5sixseven -twohj3seven3fourblqqbphcbfive -6one7twovjfqlsdgnrtzlzmjxgfljs -1nv -22five27two -3sevenlgeighteight -khpjmtsskfivefivexbjnkdtwogmxcxrqdpl2 -zmvpjtm6gzgztjrtnmgpsevenfive28vjvhmnr -9four71 -9zghgdjs -3oneqcjhsbv9threefive -47rsggonennqmbbckcdd31three -sevenfivesixone5eight -48hcmlcone8x6 -three9threesixjtxhlm3eightgtrskhqfjtgfjbcfdt -5ninefrpqjdhkkcldvhqkljpqpb1 -969nine -ninenine8ctprmxkvnine3xkl -seven648lpmxdn92 -rjhvlnz5two -dlvqhfmp587 -sevensix6 -eightsix34fourlgxrndbjjx9mztwo -czlpflntvpc1qnl2 -9seven8qsixbjoneeight -snnjcseventwo6qst -ndxgj756zqgt -krczgjpbfp199three4six -cjeightwoone8 -ffmddcrh7rrxhpnlkkdl -nine9hhppdvfczxkjninefivecdp -8eight19 -4fiveeightthree2twotwo -nine2four4941seven -fournine5twodqbkbjjmmqsn -nzqgngfxftwo6 -5bmlfbsql2sevenjrxkkdtwoone -jfeightwoppxbpgzdljnmmpvrckv8 -chj66fouronefourvcdd -fourzvgbsgkmgslntrzxtxvjnmhk5v7 -1fnzftqmtj9gqkblpknq6blmlkxbzhdsdljvqfour -116rqpdqq -xslxqcmlchmqlzmkxbk79hnlhthreesnnmnht -sixfive8kjhrfdxrtfour -nlv71clmzbnine6 -42one8lz -qspsdj2gv6vl8six5 -5gctkjzxlr2twoseventhree -rmgmkvqeightpfmrxqmvkg8 -3sixnjrjbbzl3 -1nineseven4three7qhdsxvbmlk -fourjbznsbgsn2pgxrzlkkjtctm3eight5 -36fourninecppsqfflbcbljnfgh2 -eight211ninegnfvhfxqcmpmeight -vbsg73 -3ninetwoonerbzcglkmdg -76ngkrtfonecltwovvgvgznzbmxm -977eighteightwocp -fxskxcdkdeight2225 -seven98rpzjxscseven3vtbbhqjrjfk -sevenseven97jxh -sevenfourfivexsspnqjnlxtbrfour24 -fivefive5two91six -gg2ptrsdxtfjtzztthree8 -eight2ncmps1qsix25 -eight486zfqfmgchtrrbcrjsevenrcqtxnqnrb -7vgn31lvqqvkdqlpddmllbn9 -1hlgrlmctseveneight9xfsfseven -onefourdqzvlh7 -four543ninethree -4seven1one -79twogmjcngj7rseven3 -xxtkcbkgqfldssix4five4nine -tqxnnspd7sevenvljzl2scsbkhqdq -cbz3rczscjfxtzfivenbjqone -threekkcjlmvkfrsgz6r -1sixvppcksdvrz7 -dvngzs74eight9 -qrncqtqxkfrndcrrpjcglfonesix75seven -eight6cksxfdthreefive2eight -four51sixfschln6 -hblmcggzgqsix2two -93two985 -78six6 -6sxmd289nine152 -gmpdcdcr4xzmhq3 -5threehpdmq -eight54xcrlsv8three4 -35twofourfivenine4tjthd -6kch9 -7fjlvptwo2ztrggpmsntwo -7twosix6kmdnvspnqgjxcdtgrspjj7 -tsix8fivethree -2pggbgxnft7 -sixthree69j -24l -cpzltvslq9nfhcv -six46eightsixsixbblvjjkvntmm -7five3 -six2three -seven2xxxhhjnl53sixjtgbnvh6 -fiveeightj1mrfvzfour3p -6foureight588zpjdcxlrshtwonine -xvtwonesix7prcjfsxjksknxqqsmsix -eight3fivexmrs1eightnc -vczdhchhsmlx7zdlcgfzrcgkcnqdvdtphxqqjxnsbd -six2fxqqdtrkgqpgjrvhxtsbqzz -twotwofour4six -9nzcvxthree -kggfkpvhrronep238nine -41seven4sevenfourvrmxkhpcmskbctwo -nbttnvh8nlhldjstkvdxxlvqeightoneights -tjqdkfourthree466 -twothbcvstwotwo2xpnqrldsmdtscnrp -sevennine3 -twodhbtlnzrt418dlszqkbc78 -3four8threeonetwoneh -drtcjpmrlnine3vgf8kssrsssgpnseven -eight78jqjjkgtbcckdndhdvz57q -five59onesixsevenflls -63bbznssjjsvt4 -fqkgmcrxf6gkcninesevennfzhccqtfour9 -5nine2three -gfkhpkfgb9four49rqcjrjkglpzxr -ds28eight33xl -qdgnn9ninecpcv -2sevenrlfkzmktzgsevenzzgxfrmp -twovpthxmxqgr94 -sk3gbmrknrmm -7sevenrpxjvzeightsix -9zxzqglvxqm6jphmvfsqvjjqsl -9kqmnkthcdhtwovbrqzftst3 -eight669zvrdpv -shgjkgthreeznz69pjltseven -ninebc5eight -5l -onesix5five2clxllfour -71three2fivecplsnlgsmthree -twofourone6fm7four26eightwox -7three9ftpvvbzpjzsixssxbqcfsix4 -92eightlsgrmpqtpptxrdfxthreemvlxfpsevenoneightdd -eight7three -drxxcghbsevenninenineljtczntp6 -nine55cpqfkdrthree3 -7fivefp3eight -97nine1ninexprdpvqzps -four3eightpgbdhnmqvhjjhg6frqkpqzbtwoner -3threefivesevenrvr3sixthree -sixs6zl184 -fourlfkxcvqkllbtz45threefivesix -2twodvklqcqdjjdnpx84xgthree4 -eightfour8dnqmlqmxd9cmt8 -t4sixkkfhgmn83eight -eightoneninehqddxnine75vppqhlcm -1threesdvsszeight5dcsgrsv -seven776smjhhb -onevmr62dqzt7 -pqxtspl19threesevenkjvxjdhxkseven -cgkvmx5lffclxgtsnseven -fqjctfrrlmmnpeightone19nineqgsnsqbjk -8twoone -c6eightonep3gxjnsjtwo3 -sixthree36sevenseven -5vgfsdkzbxmvxncxjpsxffcbnr62kmgmhcmkq -nineeightfour9kvdmxg5nnhrf -5blqszh97fhgpbdn44 -nhzbqprgptnineflxgvfkvlp453two -kpcqvjcjcj6dfpsljlrxdlzbf8grsnsdmklp -1zkjbnln -four2xvxrrvs -nine5nfmbxnrgfnine8onekqcnine -oneonedd8 -rr44 -8bckneightnqmkvqhkkmxfour -2pznjcxlj4onenine433 -nhmhkcqbsrrthreeeighttwo3f5 -eight64sixninefivethreecfbbdk -csmoneight1hrsevenfivesevenone756 -9qdrxl -26two3jq -pnrskrrvtonesevenrmkcxcm2five8five -sfvfr8three69three7fs -seven52bkslnnfrbqvmblknq3f4 -zqmtdtp31threesevennine3 -9tbvvjstzmdpqnpbmrb32cbdjgtsjndjrps3ckpmspm -5four4rvmtkppghb9 -24ftjxbdq3nine -ltj2oneeightonesix -76three2sevennine -hfnzxcjfxgseven5cpph3 -2one966dpjlgfqbmceightthreenine -5one9smzz76eight -348tworhzvqjdmqtwo -cjsvvksgzkktwo7hsfkrhkcsbrqcnrz26 -threethreez8 -m3335cdgbxqn5twodmcqk -27eight4 -sfmspqbzr9eight -rscxzq2fqlhbbhvkdbzqzqhzfourninepclrkkdrtwosix -pxbld2twonef -plpbbkvxqpvdxqcstp5threevljjqsqxsevenseven -2sevensix9 -5413sxmtrdjtcmdqpbpcprsix -tpdqxscxjldqvzncbvrpr9cvkqdffvfh8four -six14 -nsmqttrbhrznvonecmlxtdclnbk3 -ninecgbqh6twoctsixthreefive -hqsgonesix3oneightklm -cxxbjptkvkcttddmtwo37one5 -v13two -txxm84kmrpdkxhtbntkhj4four5 -jsrzgnine8nrmzpgf5sqdz -4six9dkxttsthreedgvjkqpk -msnrq7 -t2five4vtwo7sevenrjdrzvb -2rxbdzlszjseven7 -gmmninesix3119ninemdnprsmd -ninesevenpbfx6fourfivefdvhrsctztrheight -qk3two317hnpkqxbmkb3 -oneone6sixdzdmfonefiveone -427sixfive -17njgbgljkpxvhph -4hnfvpbvzxl6three -5sixnllvrvpjpv -3sevenfzjltglsjkdknfnmpsvfive6xdsm2 -1pxp8onesix -xclcfthreeln9ndqhvdxknkjzv4 -6fourtwo2seven1fcd -1eightseven4 -four21eightlfjzb -nine9ninenine81 -eight8zpfsshlqbdlfourmch5four -6sixjdmjjgmsk -ninesix8threetwoxtqdsffxlk6 -dgsddfcnnc3sevenseven532one -lsevennineninefive851dtqzv -nmrxfsmfcscftvzzbggglsfour6 -threesmxqlgmpvtwokvrx361eight -brbkgqcblcxghjp34bpnrctz -sixbzxfbfsjth14pqpvjqfmr -oneseven99 -7four6562zjjxxjlvfdqbssmcx -8fjssqgzthree4five3 -fourckmtsssqgdgcvmqhcqlcqqdhv5eight -bphtzndpdrfivefour8nine5 -ninesix57jvjtwo36vzljdfnndv -eightfourfivesixone2vg -5sevenkdgcmjthdxpxprcdnzpffsixcjmh2 -9cvldprttjk1 -seven6fivesfjjshfqmsjvfpc -eightsixstmhlldl21fourvgsmdlcd1 -5nv1two -tsqxlfnd6rtcvcv5 -eight3zdljlvkbp7hfive5xzgzspsnfour -945sevennrtnn57 -562 -3vtnlsfoursjbgbqmlx6 -8lprsrtvrh9two3 -pssfncbhqpfour1dgcjqpccfzfntphmtjthree1sixfour -rchfmfp18998rsbx -nineonedmlffz5 -seven2sevenonetwo -nine3gxttrkkzpj933mjzhphl -cdpqqhrcrrnspsr378two -fourrprdlkvqj8tntfttwofivesevenqmcsgpljvnl -978sixskr2gkrcgn -jcvldmcdqbjdcxhjcgngsevenfive2cfcmbb4 -szlsvrzzkseventwoone6ninesevensj -gzboneightmsblxgzmsq5seven -seven5eight5 -tsblj5onebkx882 -7kdgdfvx3sevenczgf -94g14onenine -7fournrkdxz4threethree -8eightqtworlcxtv4 -rbkbdsqbfour39eighteightwoxn -cxgmxtoneninennqtmzml6dq -8fivefour9 -8bhspzfsjr9 -fivekzgvvfour8sevensix4vlphpblsp -six63kbbxrfivefive5 -eight5gmkrhrkjjxhb -xtcfivepntwoeight9seven -6nine8fivenine2mf -5fourbthreenineslxfgtqrxcv5four -4vhkxmlsvfg -scphnsbz9h6qnlhcqmgl -tbbcqfxrllszbseventwofivethreeninef1 -zkvtlscldhngtk59 -one6fourrmftxfsvmtwo874 -37threeonefive4 -lrnnspbrgd6jzxtbninesevenngnpsljcr -xhldmfc4five76five -qrzfivexklqcjdnine46 -jkgb6ninesix41threeseven -134628twozlm -8ffrzgtbbfgfive2ninethreem -2132 -7xf -mfhmshvfivenfzjhslq7nfcfgvjhs8 -seven3248 -pvpdpxpg135seven9vpcpgrzlpjblmd -shnslhthreefourtwodnpfr7seven -6hxhhmfivesixseven -vppgmfivethreefivesevensix2two -hp98 -phlskgmgrjsbtq2gkjvrgsd -kkfourthree9fhnpdqcqhtwo -ftnvkprhvllkh9n -71one7twofourfourqtfmc6 -eightfivehssmqsptconefive4 -ninejcfqknhcfpcbcsmnpvn4six5j -one7jvmtxkjzfive -twof9pqcgdfqsq4d7 -krczdrpxbhsngqdvsqb1four7mb7lldv -seven9634tgcsplgmfivetwo -vjvpstpbgtsevennvpsvch97rslh4onefour -zbtgjgq23seven7lbnzdpnkzf -zndbhclr714 -twofive3 -9eight2twojxzdkptwo -gzqfcqpxnfhtb28dvfeight38 -rsqvgsqv9tdlvssj -f78hjftphgcv8bqgrckgldone -fivethreetjg2 -6vtqgdkxsmj -xgjdndnpsevenzfl6tfgxltvcthree -threenine82gqnffkvm -zmlblc4fiveseven3two -msmlvbnqbt9 -144bfcbsjztmdldveight -chceightwofivemcfrxv266 -two9f7gzhhsf6 -ninetwoffour8sevenjngv -foureight22g7twoonemlvq -one78ptfgbbvx -fx5 -5rvz2two -913 -9eightnkvhcksoneqsqgntfthdtjm -one1sixcsccdvbxzx -sevenoneninethree4one7seven2 -jqseightwockmxjd3gfmlhbn6seven7sevenkhcr -sevenqqhs4onemcn -fourseven3nine7pcn -sjjpsthkdfeightcsvlcvhltv6 -qpc16five -3jplhrj2threetwofpvrthree -4sixsix9two -one1eighteight -5tg -256five9 -seven9crnff9eighteight -16five1one4kqllsltrtn -eight3three -seventwoqtlxj8 -74seven5 -2five7mmgsbfc -five7four -bmtkcxvcj997eight -cpgrpgxtgkqr9 -sevenmdqtqhfvnknine929xm -nsix27vzglsevenseven63 -six1nqpsgtrllsnhmbnqxrdvrcx8s -eighttwoflrvzfq262 -twosxtf866hfhxn4fourone -3fourzbrtmd47three -four99eightbcldqfvrm -871 -2twobdtnzzqgvfggjntvgpnqslbdctppnfzpfpcbvzqccq -sdmkzhb8lnpjntj7 -threembr1 -5fd1sevenpsdpdlnb16 -7mnkkvpzrrnslfksrninexmpnfpbzhkx -nfrnvtt8 -24dsffiveqzmjrjznfksrknrfn -5foureight3pn3 -nine9three -nine74cmxrdvcxf3pdhbfour -frjnzrsixone53eight -four41fourhfjnjhpkzp -939rdjhlfpjsix -4kdkcq9two -329fivefive98 -65485 -dfsevensixmdbfour7jhxsfourfour -rqtwonerdkf3eight6fourfour -twoqnfthree5fx -rtwone1two89ntwo9 -sixskqssbccfour7fivevcmsevendqbfcvks -sgtwovmzmzm9 -vk9 -seventhree4 -48mv3eightnine -six7gxnj4six3 -twotwosixlm55dmzdrntzthreeseven -fivemhcdlm8fivemkffllv9 -fkxzdh69twoonesbrfhntk -zfourthreeseven1kllk -6ninethreefiveqdct -nineeight136three5nxvj -fivecpbkhqxpmf46twotxtfrhmvboneone -brrfqninetwohgqnkfctkseven1 -npblhpcpfivehdsnine34 -vksix4fourvrbfmjcrhb78 -72xfmds46threefive -five1kq8eight56three -3sevenfvcsglnjtbhdkqf -6tr6qxqrmstqg -15five5 -fthfvffour85 -seven81fouronefive -dhkknlbfjrnsfcvvkk9seveneightwos -2lngrlvrk4shgktcbpfonefivenine2 -sevenhhlrfqmzn2 -6seven927gdczblhjlmrxnjqfktwoneq -7phbj9fourvbx31seven6 -146 -jnqxslzpsxdftrqczq764 -tmbjdldtwogfvxhnvsfp8tzzp -fourgv68bblxfktsfdg98 -36tnrmd2jrllk2npbrctjcjthm -mx3nine3hkslkb5 -xvmgtlzmrfjcmqgtworc3 -vxscrns1lclnxtwo -foursevenone534 -jdmrj1sixkzdxn -two9threenine -2sevendsmlzh13jlslmvtnine -nine8nine -gthbsq953kxckzppcxqzl3 -xnrgzjzrbp5rptrpbsdgsqfeight5 -1sevendnmxkpdsrmrfkpmxcq22sixmdmvqlgpnbcxf -eight658x14fq -rzvgmdltnz9nvthrjvpzqf -9oneightgl -dsbtb88 -three4fourninelzvqhvjpk6 -seven59fourthreed -3671 -66nineeight8two -eightlszxlsxlcq3sixskqhj4gkblpj -three2eighttwothree -nine853qttjrjptxttwortkhmjss -twosix35 -5948lspjxzpbmthfive -fourthree8 -fourfivevbbqpppqrkkzjqqbnine3 -8nine4xszllqzzonesix2nine -crgnbqrfourrzjbpnnsqthreethreefbnine85 -dx79xjkcpxsndsrbnjlbnine2 -9nine89 -one7qmv1 -dlpbzxfm536392fp -3seventhree8eighttwoeightfive -twongjrfkcb66 -2eightseven8 -zffrln57eighttbqsgzbzhrzxt5kxxlcxb -one5three621ninetwonnprsbmm -3vmslzzp8xcpcgvf -threesix93 -seven3sixfnbbbeighttwo1fivezglzb -kgk7 -48seven2ccztcfnv5tzkrxffour -xczvzdjthreeeight6hnffivexxtmqs79 -three4nine36threehjp -nineqtdtmmpjpkzpxmmfive83sevenseventhree -22jfdpndrcvxbgz -7bljfctkbpc -4bfblqrphseven -fklxmcqxthmnvrlc9 -4seven9zspgftgvd53dsdkhgbns46 -7seven664fdqkcqtr9 -dvxtkqfqbhrllbone3six3 -4ktplgtgzlf3eightfxslssr -six2bhsjknjmgdddgnb6tbhvxbf29nine -two93twofngr8four -oneoneftmqvblcrjnng7jvch97one -9fivexmzstmlrmztwohsqmzfivehseven -5two2hggzchnn -one28ptdlfourgnrjftqd4vxfdrfx7 -six6zvkcszt4tfpkeightvdkjzbb -7oneftjp -1sevenseven9fsp -jqtznvrq8one11fivesix -3ninedkqxtmoneighthkt -8k -931 -clhvprlljttm9 -four14bfgf4eightwoc -xrflnnfb2rlv7twoseven2six -6366hlgklvjvxxlbkxgb -nbkxvp3eightgnznqqjbt5seven -98sntdts -cneightwotdkfxxxjfdpz3zkkthree -five1sfhq1lhhvjb -zdd56tcdchkvnbn -sevenhtpbmbntfivethree9scjfivenine -2spxggcvsvm4msdszqtml -4twoxsevencjgnine -89eightonetwo3ghqbckqkn -fvsgljnzgzfive1slhbxxhsrlmfivexqnkmtnzx -1g1 -94mcreight -threefntlsvvfnine9 -b3hnhvjhtrrv -11fourthree46 -plhclxcjrsgspx3b8fivecbx -mvjxqnqxtwo89bfive -three9nkjrh6two3 -dgprgjdgcrtqxgvknnk9six -dmbljtqg66zxjr95nine2seven -vdxoneight6 -22two9 -7oneppgrjnmrvchvsznsgfivexxdt7 -1three4mzc -bdnhvtsjmdnklsxbtmnztqjtpnz6fivesevenfourzddgsrfmlq -krzm2twotwo65sixfhpplvcgcs -qzcvbvsfive1oneqzc9threesevenseven -threesixninekghkvvzd4 -txqjpmlvdlpm7 -eightsix1l96xrljgg -two63d32six -8nine1fivesixfive3eightwos -sixninenkrpsix2nf4 -four2seven35four9threensbv -ncjhcskrx6 -3eightcpssngjlsqvmsxqqpldhsxsthreelzgzn -6zjnmxrgcz -9bbvkvnbmzshtdzxgqnqmqtthree -four2kqmzfgvpk35rhmqhtrqmfourhjxxfour -9eightfivefrpqtzmkkgkvjbbqmsqvq -eightsevenzpskfbrmcgzjjpnlgr51bdlcmsxhf -pt8two6seveneightjsqxjmlf4six -phjclrmpzm1292gdfivenine -sixfourtwo1 -9tvcnzknine2rdnqfive81 -sixtwopvxjcnmone2kxzxgmn -twosixpcntbtfivenine4two -rxdgeightone86twobzmnlgkdc -4two1twovtldl8one -fiveb1 -212three6twofour84 -74tstlfmrmcj -sixgxtwotmrmzkfsj9 -eighthksxmf144xltwo8 -mthjxjhnqxnhcbxg783 -prptwonehhdlrd71threeone -59fivefnsmzfsix -ninesixonetwo9six6jtptone -eight9ninefivezqvpstsevenjvcjmdcscnzlqsfnhnrnmn -2ckgjml4rcprzj7tp6 -sevenfivesevennhg136 -ninesevenvhl5 -fzflrseven1five5seven -seven5lcfxp -bqhjg4three3 -three8ninegtonetwo46 -cvdpr8 -32fivehfsdhxgjnn -sdndcpccpvdzdgn9fourlnslcmbtwojphzpnvrnp -9cqkgdf7fxgdfcllvnnmzpptninesixone9 -3chllzcgq5fivebffm9 -sqmtj4qlhlcrmrnb38v4dsix -sevennine84bcpvqjcrxpvtcgfhlfhncplktf -qkzxvstdgnfour4two -jkhoneonesixfiveone14lvzn -threethreefivensvlbfour2four -vgqlhqfrlfourlzcgppdbhq57 -bqzpzbtwolprtwo9 -lfjs9six1five2fzcldvnpxtmhsix -kslcntz36nine -nineseven8rzccgfhzsjnjveighttwo -three3fourfivedmjlgqfhmninemst8 -4qxvzgfvctwo73 -75961fivefourzg -spcbt66sevennine4four -hhb1 -dtmoneight9 -3mbctjhfmr2fourthreeseven86 -sixjsbmvzql6gfnttq -1vknfgmznmnzpgvsp3bsksdsevenfourrk -six4six7ninepfxjsshthree -4rqgzpnqcg8skfgksjone3four8 -seven5zkljftwo -76sctscqtsfcninefourrgmsbsxv9six -46fpdqhkfjzgtclfchbbsjcbjhsbkqggzhlb6four -bshbvfourzc79lvvdsqjksmzmqpbvrsrbtg7 -jdqmtfeight59fourtwo -ninefivejsl3 -94z7fouroneeight -5nbmvgheightfive -sixseven5one9ngk3 -eight3jddmgqnzcfjsvrd6five6kmbxss -seveneight9fourthree -eight83 -3spltxvtbg -92shzldthreefpckdtqhm7fivezzkdlz -6two9threeztrzxphhksqc -ninedlone3 -eight4nineonefournsmdgkdszt -9cpxhnksktwo15fivefkq -144eight77 -1sixjscflltdrgclmgrszdfive7lc -ttmfsx9dzgcqjzlzhvlfqrsj4six -846 -fiveseven7 -kqtwone2ninefour7fghmntkn -8r8one -5nnzqqgxl4gbgnzntfrhqzeight -onevpkxvrone8 -79klfd -gzrjvck1sixqnfdjxfive9eightcmhmsjpl -nszqhdfsixsixb3threenfiveqskccbffd -srbn928eight -eight2eightfivekmnjkndgrhjdpvxk3 -9four11oneeight -seven6fivezzktmsixv -fivebvtnzr4threeonetld68 -mgbfjcjbqctt71fgdbmmqdlhpxnpmvx -rjprxbxrfk233 -nxbjxbcvvskeightfiveglpnhbzz27four -kstwo2 -2btbzfournbfcxnvlvcbsjmplnprcrg -mkk6three271 -tfncrvlnfdmntdrmjqqtknsgpq671onethree -eight8twofivex -phreightfive81hftbkbdnztt -onetbhqqlcbqrlfzrqbtbl9ntcgvxr1rhgrspqkgklz -gckbonekhzcjhdb5 -twothree1lfivetwolpdxhn8 -threebqmxgpjfbzrrrrgdt8 -threejvlpxpfm9four4threeone -five68onesevennineone9two -mjqjrqmeight73 -fvfgrdppszgdhmninenineone7759 -lrhchsonek3twobblvn9bdmcbt -mdcqxbz84five6ninetwonergj -eightnine548ttfiveeight7 -74mfftzxhkl4 -seven5mdmrxlp -ptb76ndfpbtljpkhjthdfmsdddjssm -7vkeight -bzzpvht5fourthreeseven8 -rztztsix12nine -fvpqdnphtd1mmrhppbd2 -h8dpbvs2tjlqgfxhhbeight -51one -two86 -sixnine7sixseventwo34 -two45xjcpcnhgbsb1five7 -qqkzvpsixfivepfzdhtl92six4rhp -two6vqtxvxrvzpz -1qqsfrgdbsm8five -threeeightsix36xvtm -nine5eightczhsix3twoprztckvb -pxrsgpszonepdjvxcblqzkr61seven11 -5sevenonesevensix4six1dvhrx -cdxnbseven9qsevenvbv4 -sixlgjt3 -dhpxhpbkq3lc6rkjlpdz4five5pctfzsplrf -1kmsmgjpmkqfckr -sixeight1k44 -52qdfp1b8 -86fourthree42 -six2fourpjtsvskrxtmgxnj2one3dn -rjtfqxvfm88seventhreeeighttwo -fivepgfvxcds64sevenhg -glvhcrgbtphxfsfourthreerqhjxpzone5gh -1sevenone34 -689five9ninetwotwo4 -6two92sixjb1cbhmrq -fiverrvllhbgcsskh2 -foureight6fhtx1five8eight -pqvvjkhtxkxcjkrf9mn -threefive2hs6one6jhkbdh -twoninefzflrqqzvp2xnr8 -one51 -7bjpnfsgpszrfk5fourthreebvvn -six74 -twozcgbrrhxcpznx9dlcgdchpndcdc -nines566 -one72zshxlsix -vseven4fouronenine6 -7four1nine2threekzjbs4 -onecq3four -twodcrx8 -four35sjjhpfftzsixfqctsfonefiveseven -sxqnssjtwothree2 -8fdpjrztwoseventwo5rmqvoneeight -pjlbnl3rg3shchseven -zdcrnpddv2 -eight2foureighttgjcxtf2 -ghhxlxqttvonerh96715twonectr -9hmfxxrsdbsixbtwo7sevensix -32ghjqjfp7three4one -197 -twon8five2 -vtwobrlhqsq1twothreesixthree -xbdxninefour8seven -five39 -621eightsix -21fvdd11tsdzhjspzld4 -7seventwoeightfpnkhxmvc -96sjrcvzxsevenfqt4seven9 -xzxmtsrhbfivenineninerxgcrx9one -5pzgmrgrg2kdgl9one -lqzmttxcpp7cnfstnhtglzhssntjmsixseven6six -two711 -6onevjnvmkkx -eight7dbmznvztwo -9mlpltkt3 -7ninenine4tpjbsbtsgzttlgrtnfvr91four -foursevenq7 -six1sgtbsmgft9 -nineone28fourjtwo8 -76threebgqvh6lfbkdmfvcthreeone3 -13cvtpqnmbv -1sevenzjhtfpbfb73rccvtnmtthree7 -4xhvshhtmxx7sevenf9 -8one1 -931fivetmdmsrrmfxrplkfvfourthreeeight -qzbthffhlg2 -one4eight33 -qfjqt9jlcthreeqkfdpfiveeight8scfnlj -fvczqbtsix2bxkgsnsix5nine7 -9qxnvlnine2phnlqzninefive -tszjsxbsixtwoeight62ffjtdnxxtwofive -one2skxg -five5onexzgzkjvtqrfourfive -twozsxzqtrqbxqqqsbcvfpgdcdpttwo1six -8mqkgptxsixhqmbqshcl -lsdlsxrhdqthreesix2sevenchjxvmsjpvrnpcblgmsix -gngrfrhbxhqkxs5fourr8three4 -jlzszzz9one -twozrbjkjpzseventwonine8dbmfdjcb -3nine36ppqone4czxvkxjzv -ld6eightseven6twosix -1jnbfive -7threeglmcdhpvq4723fivethree -seven148oneightd -sevensevenseven6sixtwosix21 -8twojhdkdrcqgmclqlldv6sevenonedjthcz -ninesevenggsjbpt5ttlrq -59sixfivefive -eight9bsmcgkseventhree66qmgpkkxnpm -fourthree73fiveseven -9five9six8threet -3eight44 -dlcbjflsix5ttvjdxzzeightcffrtfjcjpxtwostrdc -fiveone645fivellfcmqqmnine -hxdtshfive115tfvrzqhgftwojtjrcshgtq -6nqrfrhv17jdxpfmmdt4five -sevenxtpjxnrr1 -krzkthreegjnqrfbsdrkqptd33rsvrzvvffqhreight -472ggfive56hgnvz -12tkpchqtnine -vdbsctv6eightth82 -fivetngxlttf4 -5nss -5onesixsevenphxtmlqhzfcjxrknpv -gldsixrhss186seven6 -gnpksz4 -4919 -pbc19 \ No newline at end of file diff --git a/01/sample.txt b/01/sample.txt index 1ba8437..e69de29 100644 --- a/01/sample.txt +++ b/01/sample.txt @@ -1,4 +0,0 @@ -1abc2 -pqr3stu8vwx -a1b2c3d4e5f -treb7uchet \ No newline at end of file diff --git a/01/sample2.txt b/01/sample2.txt index 4316a6b..e69de29 100644 --- a/01/sample2.txt +++ b/01/sample2.txt @@ -1,7 +0,0 @@ -two1nine -eightwothree -abcone2threexyz -xtwone3four -4nineeightseven2 -zoneight234 -7pqrstsixteen \ No newline at end of file diff --git a/02/code.js b/02/code.js index f2addda..83a61e0 100644 --- a/02/code.js +++ b/02/code.js @@ -1,83 +1,27 @@ -const fs = require('fs'); +import { readFileSync } from 'node:fs'; -// const inputArray = fs.readFileSync('sample.txt').toString().split("\n"); -const inputArray = fs.readFileSync('input.txt').toString().split("\n"); - -let redMax = 0; -let greenMax = 0; -let blueMax = 0; +const inputArray = readFileSync('sample.txt').toString().split("\n"); +// const inputArray = fs.readFileSync('input.txt').toString().split("\n"); // Part One -redMax = 12; -greenMax = 13; -blueMax = 14; - -const possibleGames = []; - for (i in inputArray) { - let possible = true; - - const contents = inputArray[i].split(":"); - const gameID = parseInt(contents[0].split(" ")[1]); - const draws = contents[1].split(";"); - for (d in draws) { - const cubes = draws[d].split(","); - for (c in cubes) { - const parts = cubes[c].trim().split(" "); - const val = parseInt(parts[0]); - const color = parts[1]; - if (color === "red" && val > redMax) { - possible = false; - } else if (color === "green" && val > greenMax) { - possible = false; - } else if (color === "blue" && val > blueMax) { - possible = false; - } - } - } - - if (possible) { - possibleGames.push(gameID); - } + const contents = inputArray[i].split(" "); } -console.log(possibleGames.reduce((a, b) => a + b, 0)); +console.log(); // Part Two -const powers = []; - for (i in inputArray) { - redMax = 0; - greenMax = 0; - blueMax = 0; - - const contents = inputArray[i].split(":"); - const draws = contents[1].split(";"); - for (d in draws) { - const cubes = draws[d].split(","); - for (c in cubes) { - const parts = cubes[c].trim().split(" "); - const val = parseInt(parts[0]); - const color = parts[1]; - if (color === "red" && val > redMax) { - redMax = val; - } else if (color === "green" && val > greenMax) { - greenMax = val; - } else if (color === "blue" && val > blueMax) { - blueMax = val; - } - } - } - - powers.push(redMax * greenMax * blueMax); + const contents = inputArray[i].split(" "); } -console.log(powers.reduce((a, b) => a + b, 0)); + +console.log(); // functions diff --git a/02/input.txt b/02/input.txt index ea340a9..e69de29 100644 --- a/02/input.txt +++ b/02/input.txt @@ -1,100 +0,0 @@ -Game 1: 2 red, 2 green; 1 red, 1 green, 2 blue; 3 blue, 3 red, 3 green; 1 blue, 3 green, 7 red; 5 red, 3 green, 1 blue -Game 2: 5 green, 4 red, 7 blue; 7 red, 4 green, 4 blue; 8 green, 11 blue, 4 red; 2 red, 18 blue, 3 green; 7 red, 15 blue -Game 3: 2 green, 4 blue; 2 red, 2 green; 6 red, 1 green; 2 red, 1 green; 2 green; 5 blue, 5 red -Game 4: 10 red, 7 green, 10 blue; 8 red, 2 green; 9 green, 6 red, 5 blue; 8 green, 2 blue, 4 red; 5 green, 9 blue; 10 red, 1 green, 9 blue -Game 5: 10 blue, 7 green, 2 red; 2 blue, 4 red; 2 green, 9 blue, 8 red -Game 6: 3 green, 8 red; 1 blue, 11 red, 2 green; 2 green, 15 red, 8 blue; 13 red, 6 blue, 3 green -Game 7: 4 green, 10 red, 7 blue; 6 red, 9 blue, 9 green; 2 red, 1 blue, 6 green -Game 8: 1 red, 3 blue, 2 green; 7 green, 2 blue; 10 green, 1 red, 2 blue; 1 red -Game 9: 4 red, 3 green, 11 blue; 6 red, 4 green; 15 red, 7 blue, 7 green -Game 10: 7 red, 1 blue, 5 green; 11 red, 7 green, 1 blue; 2 green, 4 blue, 13 red -Game 11: 2 blue, 13 red, 12 green; 6 green, 5 red, 4 blue; 5 red, 11 green -Game 12: 7 blue, 3 red, 11 green; 5 red, 1 blue, 8 green; 9 green, 7 blue, 8 red -Game 13: 1 blue, 12 red; 9 red, 1 green, 1 blue; 8 red; 1 green, 4 red; 2 red -Game 14: 6 blue, 5 green, 1 red; 12 blue, 4 red, 9 green; 7 green, 6 red; 8 blue, 10 green, 4 red; 8 green, 7 red -Game 15: 15 blue, 10 red, 3 green; 9 green, 6 red, 11 blue; 3 green, 8 red, 5 blue; 12 green, 6 red, 16 blue; 11 red, 9 green, 15 blue -Game 16: 12 green, 2 red, 7 blue; 9 red, 6 blue, 9 green; 7 green, 10 blue; 9 blue, 3 red, 9 green; 5 blue, 1 red -Game 17: 4 green, 3 red, 11 blue; 8 green, 16 blue; 10 green, 12 blue, 2 red; 8 green, 2 red, 15 blue -Game 18: 6 red, 8 green; 16 blue; 4 blue, 6 red; 16 blue, 10 green, 3 red; 12 blue, 15 green; 9 blue, 1 green, 4 red -Game 19: 9 green, 9 red; 4 green, 13 red, 2 blue; 2 blue, 4 green, 3 red; 5 green, 3 blue, 3 red -Game 20: 1 green, 6 red, 12 blue; 3 green, 8 red, 11 blue; 7 green, 5 red, 2 blue; 5 green, 14 blue, 5 red -Game 21: 5 green, 1 blue, 13 red; 3 green, 13 red, 2 blue; 8 green, 12 red, 3 blue; 3 blue, 6 green, 9 red; 1 blue, 4 green, 13 red -Game 22: 8 green, 14 red, 15 blue; 10 blue, 8 red, 14 green; 15 green, 15 blue, 6 red; 14 green, 10 blue, 7 red -Game 23: 18 red, 9 green; 3 green, 1 blue, 17 red; 10 red, 16 green -Game 24: 1 red, 2 blue, 4 green; 2 red, 5 blue, 3 green; 5 green, 5 blue; 8 blue, 1 red, 3 green; 2 green, 2 red, 6 blue; 2 green, 4 blue -Game 25: 5 blue, 4 red, 1 green; 4 blue, 8 red, 1 green; 6 red, 5 blue; 8 red; 9 red, 3 blue; 1 green, 3 blue, 5 red -Game 26: 20 blue, 4 red, 15 green; 10 red, 2 green, 12 blue; 7 blue, 15 green, 9 red; 1 red, 10 green, 5 blue; 14 green, 7 red, 15 blue -Game 27: 17 red, 6 green; 6 green, 5 red, 3 blue; 4 green, 4 red, 5 blue; 3 green, 3 blue, 16 red; 4 blue, 5 green, 15 red -Game 28: 5 blue, 6 green, 1 red; 13 blue; 1 red, 9 blue, 10 green -Game 29: 1 red, 10 blue; 9 green, 6 blue, 3 red; 17 green, 1 red, 9 blue; 7 blue, 1 red; 1 red, 15 blue, 9 green; 7 green, 1 red, 4 blue -Game 30: 3 red, 11 blue, 2 green; 11 green, 8 blue, 8 red; 1 red, 3 green; 19 green, 11 blue -Game 31: 19 green, 6 red; 4 green, 10 red; 12 green, 1 blue -Game 32: 4 green, 3 blue, 10 red; 4 red, 6 blue, 3 green; 10 red, 5 blue -Game 33: 2 blue, 5 green, 5 red; 4 blue, 2 green, 4 red; 13 red, 2 green; 7 blue, 4 green, 2 red; 19 blue, 5 green, 11 red; 4 green, 18 blue, 1 red -Game 34: 6 blue, 9 red, 7 green; 7 green, 6 red, 12 blue; 3 red, 6 green, 16 blue; 3 green, 15 blue, 13 red; 2 green, 16 blue, 3 red -Game 35: 4 green; 3 green, 4 red, 1 blue; 6 red, 12 green, 2 blue -Game 36: 1 blue, 8 red, 3 green; 10 red, 5 green; 1 green, 8 red; 4 green, 1 blue, 11 red -Game 37: 2 red, 4 blue, 5 green; 2 green, 1 blue, 3 red; 8 green, 3 red, 4 blue; 1 blue, 8 green, 2 red -Game 38: 11 green, 4 blue; 2 blue, 11 green, 1 red; 12 green, 7 blue, 1 red; 7 blue, 10 green, 1 red; 13 green, 2 red; 1 red, 7 blue, 2 green -Game 39: 7 green, 1 red, 15 blue; 8 red, 7 blue; 15 red, 5 green, 6 blue -Game 40: 2 green, 12 blue, 15 red; 2 green, 6 red; 5 green, 9 red; 9 blue, 12 red; 4 green, 12 red, 12 blue; 12 red, 8 blue, 2 green -Game 41: 9 blue, 6 red, 3 green; 6 red, 2 green, 9 blue; 1 blue, 11 red -Game 42: 4 red, 3 blue, 13 green; 5 blue, 11 red, 15 green; 3 red, 12 green; 2 red, 6 blue, 3 green -Game 43: 2 green, 7 red; 11 red, 18 green, 1 blue; 13 red, 12 green, 1 blue; 15 red; 5 red, 19 green; 15 green, 5 red -Game 44: 2 red, 5 green, 7 blue; 5 green, 8 blue; 8 red, 8 green; 1 green, 1 red, 6 blue; 1 blue, 1 red -Game 45: 3 red, 3 green, 7 blue; 12 red, 17 blue; 7 green, 8 red, 14 blue; 9 green, 10 red, 13 blue; 15 green, 16 blue, 4 red -Game 46: 2 blue, 5 green; 4 red, 7 green; 15 red, 7 green -Game 47: 5 red, 9 green, 4 blue; 1 red, 9 green, 11 blue; 8 green, 1 red; 4 red, 4 blue, 3 green; 10 blue, 14 green -Game 48: 1 red, 14 blue, 11 green; 3 blue, 8 green; 5 green, 5 blue; 5 blue, 1 red, 8 green; 10 green, 2 red, 6 blue -Game 49: 11 blue, 5 red, 3 green; 7 blue, 12 red, 4 green; 9 green, 6 red; 4 green, 3 blue, 10 red -Game 50: 3 red, 8 blue, 13 green; 13 blue, 13 green; 3 green, 10 blue, 1 red; 12 green, 15 blue; 12 blue, 3 red, 8 green; 5 blue, 5 red, 4 green -Game 51: 3 green, 1 blue; 1 red; 1 green, 7 blue -Game 52: 3 red, 4 blue; 4 blue, 1 green, 2 red; 1 green, 3 red; 5 red, 1 green; 1 blue, 1 red, 1 green -Game 53: 5 red, 17 green, 4 blue; 15 red, 14 blue, 1 green; 9 blue, 5 green; 3 blue, 5 red, 9 green; 1 green, 15 blue, 10 red; 16 green, 10 blue -Game 54: 4 blue, 7 red, 1 green; 7 green, 8 red, 6 blue; 14 green, 1 blue, 5 red -Game 55: 4 blue, 4 green, 1 red; 1 green; 3 red -Game 56: 3 green, 1 red, 7 blue; 1 blue, 2 red, 3 green; 2 green, 9 red; 14 red, 8 blue, 1 green; 5 red, 13 blue; 6 red, 3 blue -Game 57: 15 green, 5 red, 5 blue; 13 green, 13 blue, 12 red; 18 green, 5 blue, 8 red; 7 green, 7 blue, 13 red -Game 58: 4 red, 2 blue, 6 green; 4 red, 3 green, 14 blue; 9 green, 3 red; 3 red, 5 blue, 11 green -Game 59: 2 red, 6 green, 1 blue; 5 blue, 1 green, 4 red; 2 red, 7 green, 6 blue; 3 green, 6 blue; 1 blue, 6 green -Game 60: 4 red, 9 green, 3 blue; 2 blue, 8 green, 6 red; 2 red, 8 green, 3 blue; 8 green, 2 red, 2 blue -Game 61: 12 red, 4 blue, 3 green; 1 blue, 2 green; 2 red, 2 green, 3 blue -Game 62: 4 red, 6 green, 14 blue; 12 green, 2 red, 4 blue; 5 blue, 5 red, 7 green -Game 63: 1 green, 5 red; 5 red, 1 blue, 1 green; 1 blue -Game 64: 6 red, 9 green, 4 blue; 8 red, 13 green; 3 blue, 8 red, 11 green; 5 red, 1 blue, 2 green; 3 blue, 7 red, 1 green -Game 65: 15 green, 10 red, 1 blue; 1 blue, 2 red, 4 green; 10 blue, 4 green -Game 66: 13 blue, 6 red, 2 green; 13 green; 10 blue, 8 green; 7 red, 10 blue, 11 green; 10 green, 1 red, 8 blue -Game 67: 5 blue, 4 green, 1 red; 2 green, 4 blue, 1 red; 7 green, 2 blue, 1 red; 1 blue, 1 green -Game 68: 2 green, 12 blue, 3 red; 5 red, 14 blue, 2 green; 6 red, 14 blue; 10 blue, 6 red, 2 green -Game 69: 7 blue, 1 red, 12 green; 10 blue, 11 green, 6 red; 4 red, 10 green, 7 blue -Game 70: 4 blue; 6 red, 2 green, 11 blue; 4 green, 3 blue, 2 red; 14 blue, 2 red, 4 green -Game 71: 5 red, 17 blue; 9 blue, 11 red, 1 green; 19 blue, 6 red; 4 red, 2 blue -Game 72: 2 green, 5 red, 1 blue; 4 green, 4 red; 4 green, 2 red; 2 blue, 2 green; 1 blue, 1 green, 5 red -Game 73: 4 red, 3 blue, 1 green; 10 red, 2 blue, 3 green; 14 red, 1 green, 2 blue; 1 blue; 3 green, 9 red, 6 blue; 11 red, 7 blue, 2 green -Game 74: 1 red, 5 blue, 10 green; 2 red, 9 blue, 9 green; 8 green, 2 red, 4 blue; 10 blue, 9 green; 12 green, 3 red, 5 blue -Game 75: 3 red, 13 blue, 6 green; 3 green, 1 red; 9 green, 1 blue, 5 red; 5 green, 13 red, 4 blue; 13 green, 2 blue, 10 red; 9 green, 3 red, 10 blue -Game 76: 14 green, 2 red, 16 blue; 2 blue, 1 red, 7 green; 14 green, 9 blue, 8 red -Game 77: 1 green, 1 blue; 1 green; 3 red, 3 blue, 1 green; 3 green, 3 red; 1 red, 2 blue -Game 78: 4 red, 13 green; 17 green, 1 blue, 2 red; 8 red, 14 green -Game 79: 4 green, 10 red, 6 blue; 5 blue, 3 red, 7 green; 6 blue, 2 red, 4 green; 2 blue, 8 red -Game 80: 19 green, 5 red; 5 green, 9 blue; 3 red, 18 blue, 10 green; 2 red, 15 green, 7 blue; 4 red, 14 green, 15 blue -Game 81: 10 red, 2 blue, 1 green; 18 red, 3 blue; 6 red, 12 blue; 1 green, 3 red, 3 blue -Game 82: 8 green, 1 blue; 2 blue, 4 red; 7 green, 1 red, 4 blue; 2 green, 3 red, 2 blue; 3 red; 4 red, 8 green, 1 blue -Game 83: 3 green, 1 blue; 1 red, 2 blue, 14 green; 8 red, 17 green -Game 84: 7 green, 4 blue, 4 red; 11 green, 17 red, 11 blue; 9 green, 5 blue, 14 red; 9 green, 10 blue, 5 red -Game 85: 1 red, 1 green; 1 blue, 8 red, 1 green; 8 green, 1 red; 8 green, 2 red, 1 blue -Game 86: 1 red, 5 blue, 1 green; 1 green, 7 red; 8 red; 3 blue, 2 red -Game 87: 7 red, 8 blue, 1 green; 8 red, 6 green; 6 red, 8 green, 10 blue -Game 88: 5 red, 4 green, 5 blue; 1 blue, 2 green; 6 green, 10 blue, 4 red; 1 red, 8 green, 1 blue -Game 89: 3 green, 7 blue, 11 red; 1 blue, 5 green, 18 red; 1 blue, 3 green, 13 red; 7 blue, 9 green, 3 red; 1 green, 8 blue, 19 red; 4 blue, 15 red, 1 green -Game 90: 3 blue, 3 red, 4 green; 14 red, 6 green, 4 blue; 1 blue, 9 red; 6 red, 1 green; 5 green, 8 red, 2 blue; 3 blue, 4 red, 3 green -Game 91: 1 red, 1 blue, 16 green; 8 red, 5 green; 1 blue, 2 red, 10 green; 3 red, 15 green, 1 blue -Game 92: 10 green, 12 blue; 6 red, 6 blue; 5 red, 12 blue; 6 red, 9 green, 2 blue; 10 blue, 3 red, 1 green; 1 red, 19 blue, 11 green -Game 93: 4 green; 5 green, 2 blue, 3 red; 1 blue, 3 red, 6 green; 2 blue, 2 red, 7 green -Game 94: 4 blue, 2 red; 6 green, 6 blue, 4 red; 8 green, 1 blue, 3 red -Game 95: 6 green, 4 blue, 15 red; 13 red, 7 blue, 3 green; 14 red, 5 blue, 6 green; 5 blue, 7 red, 2 green -Game 96: 1 red, 1 blue, 11 green; 6 blue, 2 red, 14 green; 3 green, 2 red; 9 blue, 10 green -Game 97: 10 green; 2 red, 4 green, 1 blue; 2 green, 1 red; 2 red, 1 blue, 10 green; 1 green -Game 98: 1 green, 5 blue; 2 green, 7 blue, 4 red; 2 red, 1 green, 9 blue; 4 blue, 4 red -Game 99: 3 green, 1 red, 3 blue; 12 green, 12 blue, 4 red; 12 blue, 2 red, 10 green; 4 blue, 2 red, 4 green -Game 100: 1 red, 5 blue, 2 green; 3 red, 1 blue; 1 green, 1 blue, 1 red \ No newline at end of file diff --git a/02/sample.txt b/02/sample.txt index 1cd7d33..e69de29 100644 --- a/02/sample.txt +++ b/02/sample.txt @@ -1,5 +0,0 @@ -Game 1: 3 blue, 4 red; 1 red, 2 green, 6 blue; 2 green -Game 2: 1 blue, 2 green; 3 green, 4 blue, 1 red; 1 green, 1 blue -Game 3: 8 green, 6 blue, 20 red; 5 blue, 4 red, 13 green; 5 green, 1 red -Game 4: 1 green, 3 red, 6 blue; 3 green, 6 red; 3 green, 15 blue, 14 red -Game 5: 6 red, 1 blue, 3 green; 2 blue, 1 red, 2 green \ No newline at end of file diff --git a/03/code.js b/03/code.js index 5135636..83a61e0 100644 --- a/03/code.js +++ b/03/code.js @@ -1,61 +1,16 @@ -const fs = require('fs'); +import { readFileSync } from 'node:fs'; -// const inputArray = fs.readFileSync('sample.txt').toString().split("\n"); -const inputArray = fs.readFileSync('input.txt').toString().split("\n"); +const inputArray = readFileSync('sample.txt').toString().split("\n"); +// const inputArray = fs.readFileSync('input.txt').toString().split("\n"); // Part One -const lineCount = inputArray.length; -const realPartNumbers = []; - for (i in inputArray) { - let line = inputArray[i]; - const lineLength = line.length; - const possiblePartNumbers = []; - const parsedLine = line.split(/\D+/g); - for (part of parsedLine) { - !!parseInt(part) && possiblePartNumbers.push(parseInt(part)); - } - - for (part of possiblePartNumbers) { - let isRealPart = false; - const regex = new RegExp(`(? 0 && line[startingPosition - 1] !== ".") { - isRealPart = true; - } - if (endingPosition < lineLength - 1 && line[endingPosition + 1] !== "." && !isRealPart) { - isRealPart = true; - } - if (i > 0 && !isRealPart) { - let stringAbove = inputArray[i - 1].substring(startingPosition === 0 ? startingPosition : startingPosition - 1, endingPosition != lineLength - 1 ? endingPosition + 2 : undefined); - stringAbove = stringAbove.replaceAll(".", "0"); - for (char of stringAbove) { - if (!parseInt(char) && parseInt(char) !== 0) { - isRealPart = true; - } - }; - } - if (i < lineCount - 1 && !isRealPart) { - let stringBelow = inputArray[parseInt(i) + 1].substring(startingPosition === 0 ? startingPosition : startingPosition - 1, endingPosition !== lineLength - 1 ? endingPosition + 2 : undefined); - stringBelow = stringBelow.replaceAll(".", "0"); - for (char of stringBelow) { - if (!parseInt(char) && parseInt(char) !== 0) { - isRealPart = true; - } - }; - } - - if (isRealPart) { - realPartNumbers.push(part); - } - } + const contents = inputArray[i].split(" "); } -console.log(realPartNumbers.reduce((a, b) => a + b, 0)); +console.log(); // Part Two diff --git a/03/input.txt b/03/input.txt index 764d5b6..e69de29 100644 --- a/03/input.txt +++ b/03/input.txt @@ -1,140 +0,0 @@ -...788.............................54.........501...........555.........270.................................521......893.................... -..../..*963........................*..860......................*....53...../.....................52.................&....347........428*522. -............*......41..481+.......462....$..187......678.......420....-....................&115.+...........................+............... -............707....&.........562...........*..........*.....................438....................&877..660....199..145.........71......... -.....210................356..*.........977.68.........38.......835.622.332.....*300.....131.422..............89..*.....+..........$......... -..............14..312......+..926.....*.......529..*............*...*....*.............*......%...310.......*...835..................885.... -...416../467..........................423.....*...143...132..955...356...124.........588..947....*.....512......................134&.*...... -.....................*688...=....../..........194..............................................148........*815.......................785.... -..673/.....957...............103..104............................../..&.....888......408*703.....................@......896..4..526......... -.......628....*..62.......15.....................885.............649.720.............................93........703..........#..*............ -...*....*....222..*.........*795..........%...+...#.....54.310.....................622....916.......=......./.........../.......493......956 -418..*..57........125...141.........965..382..177.......*.....-.......390.....801....*.....&...659....406....912........614.448............. -....926...................*.#.........%.................517......*......%........%.301............$........*.......694......$......&........ -..............$476....167....208..866...............86........818.200........588.......@....%.............534.....................324....... -...571.977...............*...........*551...................................%.....992..172...849.................578........814............. -......*........176.....705...../406...........42....226.........58....................................*621..........*......*....#54......... -........194.....&....................905.567...*...............*..........287...........303.........82.......600.....642....672............. -.........*...................*726......*....*.714...............341..530..+......415.../...............544....@............................. -..795.429...........$.....615........582.240.......*153...#.........-............&.........313..........*...........#.......*............... -..............443....471.......770..............651.....649.....&........*211..............*......548.235..........2.......898.............. -..........916..@..*...............*......966.................869......843......*........744..410..+..................777*....../...728...... -..976........*.....699.......763...893...*...462.......608*..................23.227.....................411.793..........984.683......*..985 -....*.2*....787........258......*.......878.........................923..............................*.....*........................674..... -.241....966...........%.........804...............589....554...307.+....#.505..........&....332...449.190......780........*322..........-540 -.................126.....837.@.........701.......%.......&......&.....581....*371.......753..-....................$....426.....=............ -...........%.....*.......&....264.......*...................127....................562.......................379*...........786...#.-....... -....376...596......................%...511.551.........868....*....................&............224..............992............817.309..... -.......-...............374....-..164........*............./..627...340..274..710...................*.......347.............................. -...535..........195.......#..278............495....................$.......*....@.....805.570......724.....#.........98..................... -...*...579*65.......................400*...........849......764@.........180..........&....+..576.............573...*....................... -...................648.162...../733.....462...........*.................................&......#....484..10$....*...............981......... -....712.....495.....*...$..........................932...............278..478.%728.....798.............*.......483.717@....593.....&........ -...........*.....738.......................474...........772..877*98....*.-.............................556................*................ -...870@..587.676............................*.......569..*............454.................=....832.249........369..264.........298*543...... -.............*....246.608*.305............227......*....429.....57..........889...745......648....*..........*.....*....................502. -............901.....*......*......................55..............*704.264*...&........................543...234....859..$.............#.... -..................693....661.....*641.................909.....800.......................779.811....789.*.................90...954$.......... -637.....60....................607.........112........*..........@.89.....................#.....*...*....601....227..................32...... -...#......+....132........410........%.....-..795*....702..........%..........495.............285.438.............*711..........346...*332.. -......237................&......925..366..........340.........658......+..282.....532...................252.............195....@............ -.13......*95...879............................................*......169..@.........%.....782....%..%..-......202.973...............765..... -................*......601.......864.....942.=195.=284........6.................351..../.#....618..409...........*...................*..965. -......673...../..862.....&.........*.....................................381.........777..................644............612.......852...... -.......*....823...............211+..228......292*....418..290............*.................................*...-89.......................... -...363..526.....77..../413................$......208...............*....80.......835/.........-...*......458..........5*214................. -..................*.&......206..........13.......................35..........338......%.......529..79..........718............&............. -........#..840..710..112..*....308...........&...618......................%.........130...917..................*......739..221.........106.. -.....205...................417....*.....891..634....@.........241.........21..............*.........465......524...8...............*48...... -.265...........*33.....431.......770.......*...........923.......%...........*.......449...61......*..............*.........$...409......... -.....403....202....226...&.............798..713....321................=...337..........*.........128.....826...=.33........655.......843.... -...................*............943..................*....449..576.835.............$...945................@..506.................88....*.... -........143...-.636...920......*...............=...580.......@...*.....729.........839...........................347...................608.. -........@...847.......*........167.546......485.................453....................365.905.643=.........692....*.........795............ -...................997.....919..........586..........374..............................*.....*.........529..*......34....660...&........573.. -..752...853......*............$...407*..............*...................928.......641.988..201...+......*........................$...+.=.... -....*......-..289.857.................403..........992......-.....206..&....../....*.............328.....28.........$..........957.552...... -.....155................506.761..............................902..+........202...578..*.............................700.................351. -.........................*...../...............909%......737..........*267...........907....981..........273............887.&............... -.135.945...............649..........319.......................413..797......468...............@................$.733.....*...155.904........ -........*510..508..964......*248...@.....68...........285.......*.......289....*.626+............76....#.....873.........723......*..800.... -.............*....&.......51.........244..*...754.....*....#.607........*....148.....................800...@...................895.....*.... -..863$....831..........................*.913.*.......326.215.............882...........774..................252....................#...929.. -................9..........438.......652........239.............................111...*......39.........497......./519.............743...... -..746.369...486.*....308......*...........736...*................495...............*...20.../............=..................%...........#... -.....*......*....786....*..224.......5.........205...397..........+.........456....833.........523*.............638......292....399..855.... -...........135.........383...../...%..&.................*....335...........*.......................669.684*.......+............&.........980 -...............974*185........680.987.........114.......117.&......755....596.../450.............-.........571.....................818..*... -..395.....................................823*......645...........*....#..............1...172...405....................*.....766....-..815.. -.....*....769.998........762.325*440.976.........................507..833.........604*...................282......$.926.668.#............... -.....280.*.....*..75...................#......314.....666.................533..........789.......863............138...........494*955....... -.........77.......*.....907....732..............-.....*...224............*....283$......*.............................................348... -.................161.......*.......................106.......@...&........339............634..513.......729..68..........890.746............ -............................551............-...368......&......21.................520............*.......#.....*........*.....+..4.......... -..................*548....&.........843..290.....=......532.......................*.....190.393.404.........240..535..830................... -......721$...............982..........*.............811..........................276......#..........753*...................715.202..375.... -..334..............................111..969.971........*..................199...............207......................792.......*.......*.... -......793-..640...........=...............@....+..763..591....542......................747...*...............220....@.............#....598.. -...........$..........&....723....72.652.........*..............#.....120...............*.....659.......%.....*...@...........435..41....... -....*875..........22..958.........*.............480.....................*............876..............44.....608...305..593...-............. -...........526...#...........329.208...@544..................885*751....756.74...........$139.=.........................*.........557....248 -950..570.....$.........&.......*...................=.......$..................$........-.......173..&801.........504..215................... -........*.......924....658......41....142*........31..937...189.....100...........&....447.840.............................804..654.....%... -.747......481...*..........849&...........836...........#............*...........447.-.....*..........862.....108....343.....*.-....41..91.. -...........*....783...........................................865..41.................154..520....367*.......*......*.....578........#...... -852...43....759.......516..66.....*....422.........978.93-...*.........@425.579..27..................../..751..326.347...................173 -.....*................*...*....204.627..$...........*..........57.287..............*........$755....356..........-.....77................... -..428..342...$335........296......................971..............%......294.968.721.546......................$...........630.............. -................................649...........624..........-835.......-...%.....$........*........384.........18..131............545.654.... -....36.114..106.............853....@.........=.....737...........*....517...414.....784...607.........411........*...........=.............. -226*....*...*..........508.....*....................*.........303................../....-........................887..173....349.179....343. -.....903.....473..............190.-702.734..........24..............734+................198.....191*402..810..........@..................... -.........712.....405......967.................257............822...........664...........................*....+.$...........441............. -....608...*.......*.........#..........796....*...../........................*................800.....747...939.356.45..325.........899..... -......*..707.......629........570..358....*.66.....56......302...............804....+...290*...*....................*...$.......756..&..815. -.....697......................-....*....357....878.........*......@...931/.......*.511.......................958..169.......772*.......+.... -...........777..369..............257.............@.567...334....785............171.........-....292...635...*......................@........ -347*..........*..*../........962....................................................968#...763..%....&....561.....136...327*777....159.708.. -....192....739..831.888.......*....304...................................715.........................................-...................... -...........................658...%.*....................71....762.......*.....&605...509.401...543..970..........761........382............. -.....948.502...520&............188.689...................*......*........538............*.........#........947..@...........*.....530*...... -........*.................................309+.172*744....481.29....@........-716...........................................227.......56.... -...........*.....930.347&........................................111..6.......................578*..........&.188.......304................. -......151...88...*.........697.........111-...546*.....663*249...........482*7..........327.......423....513...*........../.880............. -...../.........309........*....-985.........%....................619...=...................*.................335.....808....*............141 -........740............414............624..10.720*395........91...../..520......164......318...........397..........*.......560............. -........*..........27.................*.................736....*.+.............*....../...................@......344............361.....336. -.333..271..25.............958*839...991.................*.........82..........624.....286...........663.*...535...........383*.....=........ -....*......-..........368.........=....................945....693....692..........769...............-...153...*...$811........277........981 -...667...................*.........687....235.................*.....*......210.......*.834.....$.............73...........&.......71........ -............-.....129....647.300..........................%....568...611..........262...*......742...............-213..754.....73.*....208.. -..9.......19....................=.129........719$.....795..82...........................375...................................*....235.+.... -...*...............................*...348............*.............260...638........................479........165....151...846.-.......... -..257.524.......695.......787...403...*.......336......63....788......%......*.162..%.......................854*.......*.........492........ -.........*377...../......$..........852...681....*............/.........923.......=.198..996.718.....809............443...............415... -....267..............%.......................*...533......617...724........#...$...........&...&.......@.......700...........%418.....*..... -145*............401..447.....634....&..819....9................*.......362.....241.....102..............................412.........929.14.. -.........642/...*.............*....324....*....................394...#....+.........................661...................*.773.........*... -.....165........600.........492............253.918.......537.......140..+........*...................*.................773..*.....=.....433. -.....%.....10...................................*..83......$...........241.......576........*417....969...........852&.....848.821.......... -.........../...153...........25*317......628.578....*....*.........*17...................227........................................995..... -.....889*.........*.459..697............*........304......852...788....630....720*594............$...............910.801..296...939....*.... -223......235...607....*.*....802..249...233...............................$..............177/.734........828........*............/......830. -....................439..944..*...*...*...............=..482..&...............839....................349...*...$........./...........$...... -..................%...........326....3.66..........628....*...350......544-...........763*.......83.......142..792....974....#....663....... -...$...*....729.916...........................916......221................................689...............................456.........62.. -..621..436....*......#520..808........670....$......*..........121=...............780.........*844..........=..........827%......338...*.... -.............24............*............*........601.346...621......531.....452......*.....659.......-297..697..468................*.936.... -........265............905..64.&...589..960..................*.......*..........62..19.........152................*.......+.....243......962 -...........*..220......*.......757.#..............-270..697..588....461..263......*.......@373....*........464...244...688..............*... -.........272..........993.536..............................*............&......961....=..........490..198.....*................181.....236.. -......$....................*..406......................*....238..94..74............349......723............646..328............*............ -.......139......./...........*..........624.........996.784.....*...-.........61.............+........*........*............981...557..66... -..............313...776*....228...........*...749...........246.579...240.230..*.=611..........*....917..................+.......*.......... -.703..730.........................*961.764.......*......979*.........*....*...........=.....558.906...........58.875$..559.*274.549..819.... -...*..*.......637..............853............821.............65*676.47...272..=213....45.................321*.............................. -.661...964..............540.......................=....-.955............+...........$...........143.907..................1...10............. -...........660...........*..........109$.......415..353.....*...........572......878....77.........*.....................$.....*131..182/... -...........*.....963.....395..............871*............$..994...336.................................319.....88.620....................... -.......&...625......*.........7*121...........494......=...8......*....@..............................*..........*......998*973.......$..... -....691............614...795..........152............120...........238..496...........................477..........................994...... \ No newline at end of file diff --git a/03/sample.txt b/03/sample.txt index 624ea4f..e69de29 100644 --- a/03/sample.txt +++ b/03/sample.txt @@ -1,10 +0,0 @@ -467..114.. -...*...... -..35..633. -......#... -617*...... -.....+.58. -..592..... -......755. -...$.*.... -.664.598.. \ No newline at end of file diff --git a/README.md b/README.md index f43f164..2d41e1b 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,3 @@ -# adventofcode2023 +# adventofcode2025 -Solutions for the 2023 edition of the Advent of Code project: https://adventofcode.com/2023 \ No newline at end of file +Solutions for the 2025 edition of the Advent of Code project: https://adventofcode.com/2025 \ No newline at end of file diff --git a/day-template/code.js b/day-template/code.js index 4c0c8ec..83a61e0 100644 --- a/day-template/code.js +++ b/day-template/code.js @@ -1,6 +1,6 @@ -const fs = require('fs'); +import { readFileSync } from 'node:fs'; -const inputArray = fs.readFileSync('sample.txt').toString().split("\n"); +const inputArray = readFileSync('sample.txt').toString().split("\n"); // const inputArray = fs.readFileSync('input.txt').toString().split("\n"); // Part One diff --git a/day-template/input.txt b/day-template/input.txt index 168d5fc..e69de29 100644 --- a/day-template/input.txt +++ b/day-template/input.txt @@ -1,514 +0,0 @@ - [Q] [P] [P] - [G] [V] [S] [Z] [F] - [W] [V] [F] [Z] [W] [Q] - [V] [T] [N] [J] [W] [B] [W] - [Z] [L] [V] [B] [C] [R] [N] [M] -[C] [W] [R] [H] [H] [P] [T] [M] [B] -[Q] [Q] [M] [Z] [Z] [N] [G] [G] [J] -[B] [R] [B] [C] [D] [H] [D] [C] [N] - 1 2 3 4 5 6 7 8 9 - -move 3 from 6 to 2 -move 5 from 6 to 7 -move 6 from 2 to 5 -move 1 from 9 to 7 -move 1 from 1 to 9 -move 1 from 5 to 3 -move 1 from 2 to 5 -move 3 from 4 to 5 -move 10 from 7 to 3 -move 1 from 4 to 9 -move 6 from 8 to 7 -move 4 from 7 to 8 -move 1 from 7 to 3 -move 1 from 1 to 2 -move 1 from 2 to 8 -move 1 from 9 to 1 -move 3 from 9 to 4 -move 4 from 8 to 3 -move 4 from 7 to 1 -move 4 from 4 to 6 -move 2 from 8 to 7 -move 9 from 3 to 8 -move 2 from 7 to 4 -move 3 from 4 to 9 -move 4 from 1 to 9 -move 4 from 3 to 9 -move 2 from 1 to 4 -move 1 from 4 to 6 -move 3 from 3 to 2 -move 1 from 2 to 8 -move 1 from 2 to 7 -move 3 from 6 to 2 -move 2 from 6 to 7 -move 4 from 2 to 3 -move 3 from 7 to 9 -move 2 from 5 to 6 -move 15 from 9 to 4 -move 4 from 9 to 2 -move 12 from 5 to 4 -move 9 from 8 to 5 -move 25 from 4 to 7 -move 1 from 4 to 7 -move 1 from 4 to 8 -move 2 from 2 to 5 -move 1 from 4 to 2 -move 23 from 7 to 6 -move 2 from 5 to 2 -move 22 from 6 to 8 -move 4 from 5 to 9 -move 1 from 7 to 9 -move 2 from 6 to 4 -move 2 from 4 to 7 -move 25 from 8 to 3 -move 1 from 2 to 1 -move 3 from 2 to 3 -move 1 from 6 to 8 -move 1 from 1 to 8 -move 1 from 2 to 8 -move 1 from 8 to 1 -move 4 from 5 to 7 -move 1 from 8 to 4 -move 5 from 9 to 8 -move 5 from 8 to 9 -move 1 from 8 to 5 -move 3 from 5 to 4 -move 3 from 9 to 1 -move 30 from 3 to 4 -move 3 from 1 to 4 -move 2 from 9 to 5 -move 4 from 7 to 9 -move 16 from 4 to 8 -move 6 from 3 to 9 -move 3 from 7 to 3 -move 19 from 4 to 7 -move 8 from 9 to 4 -move 1 from 1 to 9 -move 13 from 7 to 9 -move 3 from 7 to 8 -move 3 from 5 to 9 -move 4 from 8 to 3 -move 2 from 7 to 3 -move 14 from 9 to 4 -move 10 from 3 to 1 -move 12 from 4 to 8 -move 6 from 1 to 9 -move 1 from 1 to 2 -move 1 from 7 to 1 -move 6 from 9 to 3 -move 17 from 8 to 6 -move 10 from 8 to 5 -move 1 from 7 to 8 -move 1 from 9 to 5 -move 2 from 3 to 1 -move 4 from 5 to 9 -move 1 from 8 to 7 -move 6 from 9 to 7 -move 4 from 4 to 2 -move 3 from 4 to 6 -move 4 from 5 to 9 -move 4 from 9 to 3 -move 1 from 2 to 4 -move 4 from 4 to 7 -move 3 from 5 to 3 -move 1 from 4 to 5 -move 5 from 1 to 2 -move 1 from 1 to 9 -move 7 from 2 to 7 -move 1 from 5 to 7 -move 8 from 3 to 5 -move 20 from 6 to 7 -move 9 from 7 to 9 -move 2 from 2 to 9 -move 2 from 3 to 1 -move 2 from 1 to 3 -move 2 from 3 to 4 -move 2 from 4 to 6 -move 1 from 3 to 9 -move 1 from 4 to 9 -move 1 from 6 to 9 -move 2 from 5 to 8 -move 2 from 8 to 5 -move 1 from 6 to 7 -move 2 from 5 to 8 -move 6 from 9 to 5 -move 2 from 8 to 6 -move 11 from 9 to 2 -move 1 from 6 to 5 -move 11 from 2 to 5 -move 1 from 6 to 4 -move 7 from 5 to 9 -move 7 from 9 to 1 -move 1 from 4 to 9 -move 28 from 7 to 5 -move 1 from 7 to 5 -move 5 from 5 to 9 -move 5 from 9 to 3 -move 6 from 1 to 8 -move 1 from 1 to 7 -move 5 from 3 to 2 -move 1 from 7 to 8 -move 7 from 8 to 1 -move 1 from 9 to 4 -move 2 from 2 to 5 -move 22 from 5 to 3 -move 1 from 7 to 8 -move 1 from 4 to 7 -move 1 from 8 to 9 -move 1 from 9 to 4 -move 14 from 5 to 7 -move 5 from 5 to 9 -move 19 from 3 to 4 -move 1 from 2 to 9 -move 2 from 2 to 5 -move 1 from 5 to 1 -move 6 from 1 to 7 -move 2 from 7 to 6 -move 1 from 1 to 9 -move 2 from 5 to 8 -move 8 from 4 to 5 -move 3 from 4 to 7 -move 3 from 3 to 5 -move 2 from 8 to 9 -move 16 from 7 to 5 -move 9 from 4 to 6 -move 22 from 5 to 3 -move 1 from 5 to 8 -move 1 from 8 to 7 -move 10 from 3 to 4 -move 1 from 5 to 4 -move 10 from 4 to 5 -move 8 from 5 to 2 -move 5 from 2 to 7 -move 5 from 7 to 1 -move 4 from 7 to 6 -move 3 from 9 to 7 -move 2 from 2 to 3 -move 3 from 5 to 1 -move 6 from 9 to 7 -move 5 from 7 to 8 -move 6 from 1 to 5 -move 6 from 3 to 4 -move 4 from 4 to 2 -move 1 from 4 to 6 -move 5 from 8 to 7 -move 3 from 2 to 3 -move 1 from 1 to 4 -move 1 from 1 to 9 -move 2 from 2 to 1 -move 2 from 4 to 3 -move 4 from 3 to 7 -move 3 from 7 to 3 -move 13 from 6 to 1 -move 1 from 9 to 2 -move 6 from 3 to 5 -move 8 from 1 to 4 -move 1 from 2 to 7 -move 9 from 4 to 9 -move 7 from 5 to 1 -move 2 from 5 to 6 -move 1 from 1 to 4 -move 1 from 4 to 3 -move 2 from 1 to 2 -move 5 from 3 to 6 -move 2 from 6 to 1 -move 13 from 7 to 6 -move 2 from 3 to 4 -move 2 from 2 to 9 -move 2 from 7 to 8 -move 6 from 9 to 2 -move 1 from 9 to 3 -move 1 from 5 to 2 -move 7 from 1 to 2 -move 1 from 6 to 7 -move 1 from 4 to 8 -move 1 from 3 to 1 -move 1 from 7 to 8 -move 7 from 1 to 9 -move 4 from 8 to 6 -move 1 from 5 to 3 -move 9 from 9 to 5 -move 1 from 1 to 2 -move 14 from 2 to 7 -move 2 from 9 to 3 -move 13 from 5 to 3 -move 24 from 6 to 9 -move 6 from 3 to 5 -move 14 from 7 to 9 -move 1 from 4 to 1 -move 20 from 9 to 7 -move 9 from 3 to 8 -move 15 from 9 to 6 -move 1 from 5 to 8 -move 1 from 2 to 3 -move 14 from 6 to 3 -move 2 from 3 to 4 -move 2 from 3 to 6 -move 13 from 7 to 1 -move 8 from 3 to 5 -move 1 from 3 to 9 -move 8 from 5 to 4 -move 4 from 5 to 2 -move 10 from 1 to 3 -move 6 from 4 to 5 -move 4 from 5 to 1 -move 3 from 1 to 6 -move 7 from 8 to 2 -move 4 from 4 to 3 -move 13 from 3 to 6 -move 3 from 8 to 1 -move 3 from 7 to 8 -move 3 from 8 to 4 -move 1 from 4 to 2 -move 2 from 3 to 4 -move 1 from 5 to 7 -move 4 from 7 to 1 -move 2 from 3 to 5 -move 3 from 2 to 1 -move 1 from 4 to 7 -move 7 from 2 to 4 -move 2 from 4 to 3 -move 1 from 7 to 5 -move 4 from 9 to 5 -move 1 from 4 to 2 -move 3 from 2 to 9 -move 8 from 1 to 7 -move 1 from 3 to 5 -move 7 from 5 to 7 -move 10 from 6 to 4 -move 1 from 5 to 1 -move 4 from 1 to 3 -move 9 from 7 to 6 -move 3 from 1 to 8 -move 12 from 4 to 6 -move 5 from 4 to 6 -move 2 from 9 to 3 -move 3 from 8 to 7 -move 1 from 1 to 3 -move 3 from 7 to 8 -move 5 from 7 to 5 -move 1 from 7 to 5 -move 2 from 3 to 1 -move 2 from 8 to 7 -move 3 from 5 to 1 -move 1 from 9 to 7 -move 1 from 8 to 3 -move 4 from 7 to 8 -move 4 from 5 to 9 -move 4 from 1 to 7 -move 3 from 8 to 6 -move 1 from 8 to 1 -move 1 from 7 to 1 -move 1 from 5 to 8 -move 1 from 8 to 7 -move 7 from 3 to 1 -move 3 from 9 to 1 -move 1 from 9 to 3 -move 28 from 6 to 3 -move 3 from 7 to 8 -move 2 from 8 to 2 -move 1 from 2 to 7 -move 2 from 6 to 1 -move 18 from 3 to 9 -move 5 from 3 to 4 -move 2 from 7 to 4 -move 2 from 1 to 8 -move 1 from 2 to 6 -move 7 from 6 to 4 -move 4 from 4 to 3 -move 3 from 8 to 1 -move 4 from 9 to 8 -move 1 from 4 to 8 -move 9 from 1 to 6 -move 5 from 1 to 3 -move 4 from 6 to 7 -move 7 from 6 to 3 -move 5 from 8 to 1 -move 12 from 3 to 6 -move 7 from 6 to 4 -move 4 from 3 to 5 -move 5 from 6 to 7 -move 12 from 4 to 3 -move 6 from 1 to 4 -move 4 from 4 to 2 -move 14 from 9 to 8 -move 17 from 3 to 2 -move 5 from 4 to 9 -move 1 from 9 to 6 -move 5 from 2 to 1 -move 1 from 9 to 8 -move 5 from 1 to 6 -move 2 from 2 to 6 -move 12 from 2 to 4 -move 6 from 7 to 2 -move 3 from 7 to 6 -move 3 from 9 to 8 -move 5 from 4 to 7 -move 4 from 2 to 6 -move 3 from 6 to 8 -move 5 from 8 to 2 -move 7 from 6 to 8 -move 1 from 7 to 3 -move 6 from 4 to 3 -move 1 from 8 to 1 -move 1 from 5 to 7 -move 2 from 6 to 8 -move 13 from 8 to 2 -move 3 from 5 to 4 -move 1 from 1 to 2 -move 3 from 6 to 2 -move 1 from 1 to 4 -move 4 from 4 to 8 -move 8 from 3 to 1 -move 2 from 4 to 8 -move 15 from 2 to 4 -move 16 from 8 to 3 -move 1 from 8 to 6 -move 1 from 7 to 2 -move 8 from 1 to 2 -move 1 from 6 to 8 -move 6 from 3 to 1 -move 3 from 3 to 8 -move 6 from 3 to 1 -move 6 from 2 to 9 -move 2 from 1 to 4 -move 1 from 8 to 5 -move 8 from 2 to 9 -move 8 from 1 to 4 -move 3 from 8 to 6 -move 21 from 4 to 7 -move 1 from 9 to 7 -move 2 from 6 to 8 -move 1 from 5 to 1 -move 1 from 3 to 9 -move 8 from 9 to 4 -move 1 from 1 to 7 -move 1 from 1 to 4 -move 1 from 6 to 8 -move 1 from 9 to 3 -move 2 from 9 to 5 -move 2 from 5 to 3 -move 1 from 9 to 4 -move 3 from 8 to 2 -move 1 from 1 to 4 -move 4 from 4 to 9 -move 3 from 3 to 2 -move 5 from 9 to 1 -move 17 from 7 to 1 -move 1 from 9 to 1 -move 2 from 2 to 4 -move 1 from 4 to 2 -move 8 from 2 to 9 -move 5 from 4 to 5 -move 6 from 4 to 8 -move 20 from 1 to 6 -move 2 from 9 to 8 -move 1 from 2 to 9 -move 2 from 8 to 7 -move 8 from 7 to 8 -move 4 from 5 to 9 -move 14 from 8 to 7 -move 1 from 5 to 7 -move 7 from 9 to 1 -move 3 from 6 to 4 -move 3 from 9 to 7 -move 12 from 6 to 7 -move 22 from 7 to 9 -move 2 from 2 to 5 -move 10 from 1 to 7 -move 1 from 4 to 1 -move 2 from 6 to 1 -move 1 from 1 to 3 -move 2 from 4 to 8 -move 2 from 8 to 6 -move 1 from 3 to 8 -move 1 from 4 to 1 -move 2 from 5 to 3 -move 1 from 8 to 4 -move 2 from 3 to 7 -move 19 from 9 to 7 -move 1 from 1 to 4 -move 2 from 9 to 1 -move 2 from 1 to 6 -move 1 from 6 to 5 -move 42 from 7 to 8 -move 1 from 7 to 6 -move 2 from 4 to 8 -move 7 from 6 to 8 -move 2 from 1 to 5 -move 2 from 9 to 5 -move 14 from 8 to 3 -move 22 from 8 to 2 -move 3 from 5 to 6 -move 10 from 8 to 6 -move 5 from 8 to 9 -move 12 from 6 to 7 -move 2 from 5 to 1 -move 5 from 3 to 2 -move 7 from 3 to 5 -move 2 from 5 to 1 -move 2 from 3 to 7 -move 4 from 1 to 2 -move 1 from 5 to 7 -move 1 from 5 to 4 -move 1 from 6 to 2 -move 1 from 9 to 2 -move 9 from 7 to 3 -move 1 from 4 to 1 -move 3 from 7 to 5 -move 4 from 3 to 2 -move 5 from 2 to 3 -move 2 from 5 to 2 -move 34 from 2 to 9 -move 1 from 1 to 5 -move 15 from 9 to 3 -move 2 from 3 to 2 -move 1 from 5 to 4 -move 7 from 3 to 8 -move 3 from 9 to 2 -move 6 from 9 to 4 -move 5 from 9 to 3 -move 4 from 4 to 6 -move 1 from 6 to 8 -move 1 from 3 to 5 -move 6 from 3 to 2 -move 1 from 4 to 9 -move 2 from 4 to 2 -move 4 from 5 to 8 -move 1 from 5 to 6 -move 1 from 7 to 6 -move 1 from 9 to 6 -move 1 from 7 to 2 -move 12 from 8 to 7 -move 2 from 7 to 3 -move 4 from 6 to 9 -move 7 from 9 to 4 -move 9 from 3 to 9 -move 11 from 7 to 4 -move 3 from 9 to 6 -move 1 from 4 to 1 -move 15 from 4 to 3 -move 2 from 4 to 1 -move 3 from 1 to 4 -move 17 from 3 to 7 -move 4 from 3 to 7 -move 7 from 9 to 2 -move 3 from 4 to 1 -move 4 from 6 to 9 -move 1 from 9 to 6 -move 1 from 3 to 1 -move 5 from 7 to 9 -move 8 from 9 to 4 -move 1 from 1 to 6 -move 6 from 4 to 9 -move 4 from 2 to 3 -move 1 from 4 to 3 -move 1 from 4 to 9 -move 1 from 1 to 7 -move 1 from 7 to 9 -move 3 from 6 to 2 -move 9 from 2 to 3 -move 1 from 9 to 4 -move 1 from 1 to 5 -move 12 from 7 to 6 -move 4 from 9 to 8 \ No newline at end of file