diff --git a/2023/day1/Cargo.toml b/2023/day1/Cargo.toml new file mode 100644 index 0000000..a3c4e52 --- /dev/null +++ b/2023/day1/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "day1" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/2023/day1/README.md b/2023/day1/README.md new file mode 100644 index 0000000..4825402 --- /dev/null +++ b/2023/day1/README.md @@ -0,0 +1,42 @@ +# Day 1: Trebuchet?! + +Something is wrong with global snow production, and you've been selected to take a look. +The Elves have even given you a map; on it, they've used stars to mark the top fifty +locations that are likely to be having problems. + +You've been doing this long enough to know that to restore snow operations, you need to +check all *fifty stars* by December 25th. + +Collect stars by solving puzzles. Two puzzles will be made available on each day in +the Advent calendar; the second puzzle is unlocked when you complete the first. Each +puzzle grants *one star*. Good luck! + +You try to ask why they can't just use a weather machine ("not powerful enough") and where +they're even sending you ("the sky") and why your map looks mostly blank ("you sure ask a +lot of questions") and hang on did you just say the sky ("of course, where do you think +snow comes from") when you realize that the Elves are already loading you into a +trebuchet ("please hold still, we need to strap you in"). + +As they're making the final adjustments, they discover that their calibration +document (your puzzle input) has been **amended** by a very young Elf who was apparently +just excited to show off her art skills. Consequently, the Elves are having trouble +reading the values on the document. + +The newly-improved calibration document consists of lines of text; each line originally +contained a specific **calibration value** that the Elves now need to recover. On each line, +the calibration value can be found by combining the **first digit** and the **last digit** +(in that order) to form a single **two-digit number**. + +For example: + +``` +1abc2 +pqr3stu8vwx +a1b2c3d4e5f +treb7uchet +``` + +In this example, the calibration values of these four lines are 12, 38, 15, and 77. +Adding these together produces 142. + +Consider your entire calibration document. **What is the sum of all of the calibration values?** diff --git a/2023/day1/src/input.txt b/2023/day1/src/input.txt new file mode 100644 index 0000000..a528eeb --- /dev/null +++ b/2023/day1/src/input.txt @@ -0,0 +1,1000 @@ +2qlljdqcbeight +eight47srvbfive +slconeightfoureight557m38 +xvqeightwosixnine61eightsn2tdczfhx +msixonexch1twokjbdlhchqk1 +112ninejlhhjmjzkzgdsix +6six7jr +878eightgvsqvzfthree +2jxzhlkhdktxfjjleightdfpgfxjv +mxbzgzg5three +33fivehcxcxhsqhtwo +bhfive4ths1811seven +eightfxkpsqjlpjgjcp12twoxkhllqzq7 +sixkvvhvgtcnjhjtmxnr7seven8 +csdeightwobtsxflml4eightbxbzmvhq2four +twoplpbhq3mkkhb2 +1sevenrsgrl76rqtsqqzkncrgznine +6twolnlq +nine567 +qjvhrrtdqgsp8pxrlslvtwothree9three3 +ninekxpninedjx7phcncpzq +onegmzclftbt8sixmkfnqpeight +one53foureightzpvseven9 +315foursixonefcvttgrknrgf1 +ldjx34four +fournr8ltltldqsmcd5threetwothree +seven6mffiverqgsxdxjgg6 +xzsix9vnrgczsrhcnine +2sevensevenone4eight3 +48jlqz +1sevenmpbvtgfivefive +8six1 +4plvb +mxf2ninemkrvpseven4ms +3twojhgqlfx64two3five +8six7two +msnsone25 +3dpvknhqnkpvsgrpfpfpfive2hv +4sevenrnrlndhlmmone +blzrjrgq2cmrcr2sthree5ghvlrrlxngrk +726rspnj1six6 +kmlxhrff98 +hnpcczfdc6hr2tworvqqkkzqld +53oneeighttwofourthree +mnbrf3fourfpbrdgltf2xbmbmrbjltdxbklsixoneightq +rzlj22gppksvxtkmd +1jdxsbn +tg8 +79mfzzhctvqgk +fivethreezj45d752 +hsbdxl4 +fournffclthree9fourseventhree +rnlccx4 +gtm8kqfourfsix +2sevenfivesevenvqshqjdvhz +zljs5twofour2three71three +61lppssjcmhchkdhbnlqznrbxkprkhrjlvgmk +xxnxtff9eightzzhpfgscgxrbkdgdvfivejgn +five2twonine745four +nqjbtrc5 +one8xgcshpjfknb57 +sixninevtmvnxmq1fivexsjltpxgseven +ssfzbthree8twoneqqn +2235nine +eightsixone4gf7fourckdfdvcxn +seven9zmpb +cpfthree87onellxlgjjhgshr +64threevpmszkxs +7rmxlsdqnvvmkzvjr4jjmgjrfivesixfour +4tfgdr5two1mtjbmthld5 +741two +qtfive3one +kctwo4ptmgnbr8bpjrckscfour +6four6sevensixfivetpfmjvvfdt +1fivethree4two5threetmm +ptpxxkxq72sevengbn9six2 +vcfhscnfplfive7seven5qnsdcgdmqzninekmhthklf +nine9znfmxkfnrqdgjh6kmninethree8 +4eight3 +eighttwo6threefourpqzbqfourtwonxksmbqt +638fourseven21btmxnq3 +mnljhhgmcqnz4four +vhhgjdjkcqseven59 +29cq4tvl8 +threeonethreefive85eighteighteightwolb +kdhpb381four +4one8twoxmvzfjzbqoneightcx +ptkmzzzzfcnjfctlkpdtwotwo4 +gdkzeightjbmgffzqrseight862mstxshpg +53hzzqone +slpvjsbvjkv3 +6eightnine2 +qcrq5one23 +3hlzkglq +18pjqmlfkgsqstmnine +6twotwofqblrone +qkhdk45 +sixdqkgpzrppg6dk5lgsqtwo +6four9fourpppplfcxxsevenfsqvr +hmfq83four6eightfccnjqxxh +jeight5twothreesevenqgcctwo5 +39gzc75one2ncm +3zrqbgqf5hs5five2 +seventwo4fzbbdndzcvdgxbchthreerchfvcbndncsv +1813n7rqnzbhqmkqonemqkjcmfz +5eightsevenlxxshdkh +pcb7twoninesix6five +eightfourjzdmcmrmjtqfdkhlmfcmnnsevenjtzch2 +threeeightsixdjzrssevengnine8 +zsknqnvqsx6cfqdfivezkmmgrtc +4lhkblmrpgonethree8six48five +s7gnfcfour7sspnfoureight +sixtwotwosjbskxfbjnkt3three57 +ninekhhx9gp +xksttksixone9one9 +eightsevenqdkqrkcsh8gtseven +eight45 +qqtrfqlcdqfivevcgnzjvbl1threesngjgljkq4ctbzlsdfspc +onefoureight51rrxlffourthreekbfjmkzzvn +fivexndcxfivesixthree6gdsvsxmhq +sprbznpqhjqvh749four +hcbsdlnckk6lmhmngdrfmsbtddtxmeight +frfxfivesvprl5eightthreefourjbxtkrg +seven8two +tvndjhqx7foureightxkc3f +rfbeightwortqzmsixxcrjponerznbhx3113 +jmrdxonelvlpz9three2qrklvhrbdfnpqqdhnmjlsv +2qpbcdsqtdvxmq4gqxkdptbvc +54656gl3 +gnmkdm7sevenseven3four7fhrhppmtkpzvtlfqoneighth +mvggxccshsix8one +211 +sixseven299 +pdjeight3sixqjndl +4nvjkpqbv8seventwosevenfxhrm +9rrkjff44fivethreervt +1qqvbsfghdbttrxbpvjjbsnsevenfivetthree +fhhksevenfour215 +66vqnbtonefour2qpd +spone1ninendxnqxfqvh +96hfphsnpmbx6rv +ninesevensixsix5g +7jttgkv +3gfsnineqbbfsrgpgtcjone +qtwoneeight7oneone1four +837threepzkxqfgdrml +fivejmhlvn1sevencrccgdhqzkbjt1 +nine9seven5897threehmccnbldr +four24four62hrkhpf +9drdtfcvcxll28tkrjmtwo +six9kkkrhtwo +1six7eightfivenine +ninefive78twonesz +eight95 +6fivefour1fivekvhqfxrc +16threefourfivesix +7zskvk9vv47pr7bpzz +pmptwo8sixqsqninensxqlrp +onehkfs9twochdn +6five8fivefivefive89 +sixonefourrpxrrvlxfour4ggcpnseight +seveneightblltkljcthreeone2nine +7xmlglrghhcchqhmknzn27 +4cphpdpdhxsthreetwoxgzzxvkthreethree +9kdgqtwo +5fourtmstdtone2five +gtgzkxbngmsixsone2pzrhfqfour8four +3hltczsix9kvqldhoneqrtmtmghrc +one5jdvgrlphbhone +vbns2fourqnbvfrnpr +8eightvddvoneqs +thngklbdfourpjxkhfivesevenkjbtnine3vsshx +kmbgxvpmfivevngxcr16eight +9xvvcjzcrh +9vvgrr1 +three79kszslzdzlbjmd +tcst4sixfour +293four +seven9qhjpbneight29znbctmpcqxkp8 +oneninethree72bkjksztwogt +five2sixn9kptcmqdtwo +pkqeightwo1plzbdmzdvt9 +jxxqhcxlnkm4nvbgmj +1psqeightnine87589 +threefive5jfrptftvknzsevenqtzfpmkrj +fivethree5 +sixfdjjjq93vtvcsdrvpc +srvvrvbjccnine76hlfdqksheightworkk +onefoursixfive3two9vvnbmqbrncpnztqcgjmf +3sevenqtfjxcbgeightzccnfl +llnkpfsqk2 +brlgeight2xblbvdlonejzqtlj +five9ktrljseven9pzfkqsrf6five +onepmbltmkkfr2 +sppgk1threevzlxftfklbvkvdpsonebtbbjeightn +threeseven9 +threenine1 +clpfmf3fourtwofiveeightkrn +ninexhcdsbhqrrl52lmsfour +zvthreeonetseven25four2 +eight2csevenncfzgkbdxb3hkrhjlsdlxmlfnv8 +7xzlp +4twomsthree22324 +9gzf3vfour4 +7eightvdr +7sknmjmdppfkl9 +5fnine7mjpdlrseven5xlghtk +1four6sevensixeight4lnvz +three1fivefive39 +xkrxtzdhvf8kxscmqh +9ppk4 +84threepmqzvgfhjnmbxkfgjlgnpncdf +jlf7712 +qzvxgxv4gjqprxdsc26sixsixfsbfts +22ninehjq +5xn6 +5pgzztrtgh +5kpdthjkfour +7six199fivefivelvmzsxq +5sixfour73fzmhsgxpbrqmbprhdq6gvpp +26two3 +fnoneightdxznmf46 +2threethreemskfpdsgsixseven3 +d58fivecfdfivejgkknbcxfour +9qsmvtvk4gkdmlfz1 +pzdgjbcktk5bfctqphc +fivemtwo382nqrbgqn8 +nine96bcpxxcdbnrfivekhcqnx7six +six9eight2nine7rqjbvd +6xnkllrlphfivetwo73three +6twoninenineglgpvfheightfive +fivelxhxjqkmlhrzkz6nzdrlrfthv +vbkxjhxsf56five +7676one +22sixtsvzfsl1mqzsczrflnine7 +6one1893dh +jtlvfpxnv134 +2cdnxjvzpzqhthreeninerggxgxctthnzrzrghqv7vlf +8grlzfplzdpthree59threefourrlhjcsbqmz +lvxztxseven5pksrqcq82 +ninedgkm97v +9sixeight1hmqhzvzgnzgrrbmfm +2three5ninefqx +45svbccvbdfstzfqmfiveeight5k4 +ntwone9zctzkkpbdjthreetwovgf +8kpshzspdls8nineeighteightgqzgr +fivetchvsrqk1twosevenftz9six5 +72mhgqtnpksbcvfcfivehfnhfourthreesix +694tmgkbvhf9one +2vhctqvtmqlrpvxjfive55 +onefscmpn6sixoneighttt +6fbcpl13five +jztwonesix42n9gfxnone34 +nineoneftmtwofour4eight +8ndt +thfivedsevenxqlqxpffsv22two +5fiveknzd1eight +fivefivesqggqcctfdhxdfzrtn9 +sevenninecmxhtjshqm29922nine +79lnvct6 +vtqrpdjqtbbzpjgv4eightkcpggmq37sdhbnsnkp2 +7874three +ml9tpngfshkx247 +four2vqzjeight9kvlmvkm +one9pczrqb7jnxvssnqngdktbcjbhhsx +5plrkfiveseven4 +threespprdsklbszqxkkrcseven2 +one2ncjrsrq6fgmhxpvmvnine4 +hsevenmnjknphqkvseven2nineeight +rsqt9six +kvgljgskt1shjtthree +ninejtbdntj75bmxndbqvbsixrcsxbcdkbsthree +8ninepzglkbrbl54fivefour6 +seven8five84sjchnqcjfzninehkqfxjvtrfive +8eightrfournine5 +vkmfbd8rzjtnvfour3jsmjpsjgxnpgqb7dzcmtdg +fivedzbgnrseven2gsvhvtvffs +s2 +cvcjntbhcfivethree9oneightz +7eighttwofivethreekkrhqnrseven +ninefivekxjp5 +5twofive4onenine +8khbqlcsvhsevenkzp54seveneight +sixone7nine +one2gzxn88 +zjzsvdnmn77 +sjnzcsbbg66ctl1ninenine7nine +three3htlrblqvfgbqzldhvvhzvshfour +12drgqcqtq5 +5fourlpsixonedtzkpt95xxntdcrx +73ninefiveninemrcgl +7seven6fivetwo7six +28xtpfn1 +six7rt +c8four +bql2eightsevenfoursix2gjcncmjscdfive +tqxgzjfg4fourbxgsrhpfzsevenhljrjbqgrskcgprmqzkpds8 +4dsjds +7jskqgjtqzfhllzjbfnninenine9cgmhkllmdj +mgmsbk85fiverzxtwold +5ncgnhqh6bmlvtg1smcb6xhkvh +f23snine +3strppjqhdtmg9gljptpjxmx +fourfcpjsfiveckmzgt482nine +3hrf1oneeight4dtxftngxvsixeightwokqc +nine2dxdmlj +fvqsltrpsixsixf2 +711nine4741 +three67rthree9 +seven82nine8577 +two5four7foursixtwo19 +5twothree7cmkj +32mkgcpnh +twonine4kzrpbtcbh +eight8fourmjlpmglh6 +27eightpj7xkp +dhgvjqqsqfourpvtnbcrxdznineggm2hmtrl86 +2schnfh +64htzghlseven6 +64eight7eightczzmmpjxhz +1rjgpkrr2sfzvjrsthree67 +7onenine9eightfoursix5rzmh +3btzf5fivevzfqgmrdpvklsptlfp3 +ffiveeight9 +fourpdmxflnx7dxx1bzgmnht +ncmj6seven +2npbfiveqlpfzdp +onesevenngnfrv7 +clqgrbzm81four5mrrkbbmlhb +828 +7q68one +sevenvlsggsc7khvshfpql +r1lxgpgx2six +9crtt5ll +25nine +ftwonefiveonethreetqfbtppmpd5lzskxt4 +2txtddtg782 +xxtfhkcgtwothreenine8sixseven +68ctd +3n3fivefour9ninefive7 +qdoneightseventwosixfivetwo8gfivenrfhvvz +rnfcxlhdktjnxpthreethree8 +8schm +3zhcfive2 +qptwonemnvb5 +onethreefxz9 +rrsbvsfour5 +9nkxddqqlqzkdhbxc35krntjnpxrfour +twop1nineonefourninefive +pvgcsqxvrcrtsgtrsmrcsix2seven +237eightbszvlrjteight6 +45eight +mltnhsd88rdldqqmtmd2sixthree6 +3zchm2mzsmdmdqjs7one1mmpnlg +51bbtpfdjlgznfive9 +onerkkczm17775seven +four63one38fivergcgtqrleight +6ggpxmvc +12six43nrcdxtdsfive5 +knctwone363 +fiveeight3oneeighttwo5 +31fourndmngleight927two +2km2oneonenine +six7gknpdftxnq243 +pvllkgzmkzfive2rmzcnrxxbghd97seven +ggpbvmlgrv3 +1htjzxxhbrrtrmpnine +sixvqctcfmlz5 +6fouronesevenninezfltgfour5 +mcfrsgrbpsfourfiveeight8 +ktrlthgxzpb6five +sevenfour8 +eightfjlfcr4nineqdnvndbknmzvjhnqfhqzd7 +9threeclpdskczbl +ghhst19 +seven9fivetfivefivefive +eighteight5five +3eight1fivexmpstdtf +1six12 +1eight4ninetwobxtkzsrlsq7 +5bfour33fourzb5 +9khcntftzhzthree +572nc99five +71khpfnine3tndvzmxlnkoneeightsvqc +8934chtvkqzxfive4 +ninetwo2one +eighteight1six3lzkzmhvksxfm8flpjjxlckg +fourtwo8rhbdcxcmjtoneqbcqvzvh +onethreetwo28eight +twothree23fourfourvjxmdhmthbvbone +six57xgdnsevenhqs +4jjmjbtrfourfiveonesixddveightwoqm +2djdm5vgqxtsixsevenfknfzvrlkq +17twotqlkqkf17fntlcqdtbeight +foursevenonennthxkdxx9sixhlxdcntwo +qxrbhtn6kxr1cdnjktphbb +jtk2vfsqsdhcpq9eightwojsc +6ppfntdkkj3six54rdthree +six4dcchlqlvhhqqxvqxbqspttwo +six38three74nnbmmjgx7smc +dshfcone34jjhlhpsvgzpdr +lbgzbsgxq8 +4vxpbhjhvzjqbdzseven686 +7tgjzkrltthreexbkcrzsixsix3six +7eightkrtqvzdp92six +szkslvjxxhseven9two315xpxg +3dthreevkl7kf732 +mhqs42twoseventhree69seven +mjcgnjphtk2six +xsqdccbxldfs5onenine +1threetwovgslnseven3 +27five6two +fhgoneightfour8686 +six6eightfour71 +pvnqhcgdrtwo2hdfldftthree +threeone2vdxnkfsix +xhtwonenineseven6two4 +82csvthreethree +1threemglzrkbvjzfivethree8 +qkfcfourninetwofzjqq4mhcvfnx +zcvhlhhfcts13sevendjqvllmjqp +djxc55two +3gzpkjqmtzlsevensevenfour3tqs +sixggpj4five +fiveeightngstjsdoneczkg5 +nine45ninegrhtnfvbtn5ffjmtscxjf +2zdrxtmcmr +4ninesix7five8cxvkktdsrpjjlhpbmprb +2twoseven +six5hlmzlm1one2qfbljtjconefour +qkqncxkpbqcqt6sixeightfiverpz +4fivesixnineeighteight7 +fivethreetwo7czqhsl69 +2threepkbjrfivethreensqpzkchmbgfd9lcnfchf +2zsixseveneightxlcttbrldbfthjmpzc2 +gv4vzbrh45twosix +lmznsixninesixjdvhkclxdcgfzqclrxpcrljskmn7 +73tmvtwo9eight3 +8five9one +dkjx8nnpnfxgonethree91 +rcbeightfivechrchcfzh3eight2trc +fivelnmf4threeoneqsdkmj +7fbl3fiveqgkqkhrr +2nbpg +six64onekthrflnine +2kpcfl8ninethreeldmqnxzpg83five +g484sevenrblzqhrphfsevengd +sevenqrsevencsbcqdnqzv4 +59sixkk +sevenfhs3cvgjxzfft1kpqbxffhtwojst +rtqqseven1four2threefivesnjn +pzgcxqdpb9j +5fourfivethreeeightsix5threeeighteightwofs +nine7dxhdbgnn774one4 +8four94rmzjknkc91 +35gzlsgqgf5 +seven5dvpnslnzcrxdznine +3zkbxqnpcrdkkmdkbfbv1one7 +4gxlpbkjsc32htjxvzdfiveoneseven1 +8vnlkmqkfmnpthree65zljcsevenhcddqgjbsj +1sevenseven6sixseven3dllmjljblc6 +sixfvsqtxslmone73eight1 +seven58bpbdmtwon +khptmktwotlvvh8sljppmxtm15five +qqtbmvbbdtkfmxkqhoneeight981 +fiveckxltrbstq7929 +foursixsix6mpzvlhcsix +four2dprpl7tjplddnpt73zxxbdcnlpdb +dh1ninefive +59hpfmhfour3qjfivenbhlkkjgp +6nhldbjxdfour4gtpfcgdsfm +cqvfivekgsxfive9qsgxnv +eight4eight7 +one9gtfndld +549two2ldssk8bvsrhgstppdvj +sixone7bgxqvchcb3fivehjbclpg +6ktfxxvjhtl1 +fivethree5tlhnmbqtnl241 +one8gtrkrvhkqeightwot +bxhsxn4ninejvlrcgngonefiveseven9 +zrqdzghqjbone5jcfsone +zqsixzsmszksx112xshfkkrfzr +twosfggctdjfour5gsvtninebjjxttrbhk5 +fourtwo4vblrmtqj5 +sevennine9seven1dkbcn58 +8pbztltskcpl79hjgxsixztplzgc +pnine6rhdgbhfsqnconeightsss +five647 +3xghrx1two9 +sevenfourfour1nineeight49xnb +6eightvnfsjzjk1fivemjnz +rq9rbdt +5seven8gtrnmthj +eightone5threefiveonetbcsevenjdbm +twoonefive5eight +665one9ninecrgvnh71 +3fivepscflhn8sixsfgq3 +45sqcjonecxbzqfgdsix78seven +4fs +mdnkmfkj4six474 +bqlhlmbg46sixthree9nine +47onetwobpxvnnzqzlj67 +seventwothreefive2bgfdvchvdg515 +mbveightwotwo5onethree1dmhfq35 +p5kglzfkdrc3xm2threefour1 +n57oneeighttwotwotftgxt +1sixz1rrpkmmbqbhdcmdsevennjlltklndztwo +jl5eighttcpczp5 +m4four71 +fivezkfpjrdp121vqkbhsp +mxtxcsevenfoursixszcgqtfsj5nine +three8eight +qzbgcpjj9 +vhkgcrxtxtwo14sixfour7hchprqtfseven +onetwocxnq3fivejljbgv2 +fiveonegcslmmgtwofivetwozrfxzpjvxljgq1 +cnttseven3ninepskfours +zsj4 +s5mjgshg78 +fourtwoseven9threeeightgvkgdrhq +five1qvj2six +one4nlbddxrhnineth +seven4rrfconemkkpkone373 +999one7b1 +oneeight4tkt3 +7eightk +five6seven83 +nmtqmfl662phgfqfgvs3fourtwo +57qjprxmvllqgdf3lbh +sixnjjg5ltvtrggbm +fxfbhsbls17fzcctwoninetwo +eightjbsfdh5threesevenfzgqpxfvkghzntfrplpg7oneighthh +gbfivesevenonetwo4eight2 +eight5eightxggnbdfvnrr +six6three6sixeightone +zrjnv5threeninefour6fivefivefive +two41two7hrpxrzhvcseventwo +4hzgjpfvknjseventwogt3 +htfrtmxthn6sevenddsmdnseven +fivepqkvhnphdm8seven5fourf +395dntdk4five +7stqfkzlhmqg17one +mzlheightbjqlknkhkphxkfhcrkk17 +2fivepkdhkxplcteight +5six3two4 +1ninetwo +9lzsbhhjssix89 +2six9sixntncshzbkflh +fourjdbq8nl1five +4fiveeightclrnzrpltwoeight42 +bcfshxxkr6kzppmc4nfpzpdrfmnthreezxkjppzthree +kmpsixbvjpvdgkvgcqqtb9llfclrseven +htkhpzxbcphprzzmqthree3six9 +1cnpsix8r +nslvshhkeighteighttwo3fourchvcpcfgkcseven +foureightppdqhfdzlsix4vhtpztdeightseventbfmkk +nines7nine4csfzfxlqtcxs7 +nine79bp +khkeightcbqcdhthreeclfsc4fourfive1 +9five93eightcjntlksdqtvneight +four3jcfpckfourvkgxpxbkqv11jqfvlgmhx +sixthree47twofivethreefive9 +364eightsrlbbsrtptwofour +bxskfour4nineeightqjj +gqvsn574 +six99tjcqjvdvmtbp5onenine +jpnone9 +hdtwosix189bjgpfjtwo +7seven3mbrrhnfg +zsxfvhftszgjmbkxqp824 +twosixgbntjknzf9kvldgqv8lx +rthgvmvfhzrqplxjbh5qjqbpzrm +phrlkkl4 +twofrfmx2onerg64fqjsdxpqsixtwonetx +7eighttwoqrjf +fivefive2rzlqjkhbm86 +mphzxmckxeight5zgzhkdpfhvmbdbpffive47 +sl8 +zggtwone82tnbvqqzpkm +7sevenxhmqzqk +hzfzrrqc93eightfour1 +msztmvmgxeightninenmf97xxrdzhznkc5 +8njmlqrsevenseven41bjdzxbeight +7eightonetwoxzktcgghghg +xseightwo2jpmhnttoneztczkjbnqts +onef73sevensevenmzrbvc +3hgxkfqtfourfournskgb1 +5knjskch4skgbjsixone7 +hflrdfourpdhlrzlnq42dmqeight5one +7ninestwo +6dvtfl +9two497 +eightfnnmhs2 +jbmhszmfthreeone73dqcvjqrpbnp +98seven1eight +cpqgprqcc32ninesix1eight +fiveonebvrqmf9four5 +943smzjdc +9nslnjlzcbqfj +two6gxkqvghvdlgthree3 +nine77seven41tqf +6threeeightninefive1sevensevend +rone4five1sevenonexxqpbsdjr +sixclgfzfjqq3 +2eightsevenfnoneqdssvjkt +dhcgmvg1sevenvsqhbh +gbtdppgldnd6fgkkdgxzgeightx +fivefour5five3jmxmf5 +twoone4sbsmpdtqlone +twotwo2seven7five9 +zsix2nine7qhmfiveone6 +zbtxdrrgqlzngnn5 +64xgmvsvzdvnssixkzpdcnskfive +pcshsdtrjk5kkdcjpmmeightkvcsm +5nvvnncsevenonexln4six +eightseven5four3 +zk8oneszssdfjcxlcggcnvnzqmkt6 +fivefoursevenqplbeightx3 +jdtgszhf9 +5seven2 +fxkplfive7five +4oner +two53two +v48 +9foureightsevengmpthreebxth +dccdkmjhdtzpmlhx3 +pdd5six1sixqgnjh94rpp +nine94vbvrmnlsnine +5kxkkltwokmzfourhmqlhrs7sjltthree +eightsvsix6nfqrcvfdx7 +5vfsqkstfiveninefivesix9 +4onervseventwo7 +8mfsdgkppjjzdfrrqdcl7two6vtffour +hjsg2rkk8seventhree +hkbznnhhdtfourone1sixeight +one3vnntbscbzseighttwonek +fiveninenineszpkfmsevendfxfxg5 +qchrrrbzlsjzk8xvjxgkvvvqns3 +eightseven1 +92dpjztwofourfourcrrtrpdx9 +3three81gppshcns8c +9943nine8ninetppvpmz +fourmbscxpslsbtqzzmdjbsr18six +tdlbcgpq6766fiveeight +2nrnsc5eight +seveneightgzhtfourhz5 +nm3ninezbbbxxpk +8sixnine6ninethree +13sfmkkct73pmncdxclnn +vgsjpmstwob64six +two7twoseven5xqxjbfqnbfivefive +1zxgnkgdkseven +sevenljnineninefvvkxznt596dghfjzgdf +1threebngjvlnninefzlbvjj +fourjndnhk2five9 +8sixmhvjtvdkg +1pcgctlhkxggq6 +8hfq +eight66xndjgone8seven4 +nbmljkxzs5s1 +bnkssmdlninefivetksfbhns7vpqt +4hjnjqccmbmnine +3rclvqqfxhlqm +gdtxcrjvrfourone8qpmxfivetvd6 +8sevensix35jpdfourfdthree +1tdhsxbch +3759lg +zsxmb7one2prxjxpsix +cfjfxx4ppbqhjpvfsix +nine67fzqrqcztwo1four34 +1seven6khdn6oneseveneightwoxz +kzgpsclvrn44sixvjqmhrsr +2zvqbtdxcxvgqdtrs +bt81898nfpgxrpggsone +gbveightwohqztxvbgngtwopdbdnfzbhbrjsixthree3 +threejlgmfljn15 +3fourone132eightvhtdssxnzfcnt +4three9d9seven +qbzj5kgglthxgv +ljttvvpqdbd4seven +9threetwo +blxpddqgeightfour4977jskbr +2fpvqbmnjlg +22tone +xrstdqhlgnrmdntxttzt1 +four7ntjlbn +5mqhhtkldtwo +zfstz49two +gljszpg67 +xxddtfrseven2fiveninethreemlxghjzj +mmeightwosevenzllrjkqjktgvj1gn6nmrsc9 +qsdmsql8twoxdzrhhc +1cdqxhsnkkmpk1b +six9hfzfhs +threegbsnineqsixsix9jdvfour +two83fourpxnpgmnnjxdpsfgdd +eight5kftxcsevenseven59rdfpqcx +fourtwooneninesgkvbbsdq4kfvtk +ttwonepsfspjsp3 +3625eighteightthree4 +ninefourseven9eight4nsfmhsng +2bcfzninefivethreenine +zvsixnine2eight4hgnvzgv +52threetwoeight3 +fivegvngchprmmj4tqnqvjh4three +dmkmdtrseven2onefivenineone +seven5hvtmkklsnineqgsxglsp6 +ddjfrfq3lgrxkfourptxftxfc +mmtwo9five1gtrcc8 +2jcqzlbthstzttllks2vlnkmpfour6 +jpjtzjf2 +fourgseven8 +seventhreexmtpr2 +82twoseven6 +6bkppqrcvfourfourvqlvctgcpl5rhqcxfour +threesdcdbhjgcjhrtvseven8 +664 +7kxdkrdfour +3ktxgspnhrndzptfxzmrgkdp +eight9dvsbxjtrzcjk +nrrlxvddcvm361one +35 +7tpmjdmqnzzpctjxl +voneightonevpkonegzzslxdjjmzvvpc73 +twoone9fivefour +1ldpkzznonessixmck5 +nine4grkzsmcvlzlqzqdp2nffcklvhsn92 +4two9rhvrfsxvc +nineqlqxdvd9two6two9rthree +spdeight799qgt +1sixtwogzeightz3five +xcqrntvsz2frjqgnqxblnr +ninerkbrgrzqeight65txshjcrsghfbprjtgdp +fourbcgjqpjbp64four +jpt51rmpbf +7twosix8twothree3pzzdzbls +686 +51fivemhnkcbpnz1lghkgdtztbtqrd4 +9jkn6xtq35ninelqrsksmb9 +466zqxzlsqteightsix2eightwon +7517onetwothree +5mmsppmqnnxxjvfxxxlbtwo +ninenine53gckztmtwonedb +eight6tpjdzhqd9fourzsqdpqxtf94dc +35xvpbfour +ljsfnzq5drgsbk2hlnrgsjcjn +twoone59twofrskhscjc9nine +654pntx5eightxhkzltgdz7szfvhr +seven15nine +bqpfiven9trzmqqbsl2smrh5two +eight85seven5 +pkdlsckpkbtznlngsrxqdz1mhfsthree8nine +96eight +5one1nqjdcjgs9jzzsgnxtk +8rgxkmmlz +mjfmvvc6 +nine4seven613 +4one9two +five813 +six17xphchsevenpvrmbrlmsqbnbzpmdvm +five717 +jrteightninefivefour7fppstftgcqjfs +clcjgtzkgvhvn7vsix3 +mzcvrvtxtf62ninetwo1one3 +nineeight5five7 +btrxqfqnzgcdpbtqrd1 +jjjlfdjvgplnineflxpg3 +foursevenvjxcv4jqqcsngcrz +cdvx9mbhcbjlnine17twosix +gzfbzdglstwothreergrxvvlblh9czslhgxpninekone +zbdxcsix5five +8bbdqzlfbsssix2 +6twoone +one6twotwogv7 +rfxzbsfive6mzlftvqqdj7 +2eight2eightfivevmsixqllmhf +46two9 +14jvrfqlskz333jbsix3 +52fiveeight +hqn1three +ninenine4four +seven2two3pthreehqhbbz8rsf +fivefivextnpd7sevenkbjnnlsixninetnvjrllf +nine2fivecxttgcsbqvjgxj +twotwofjndhnfzscgxfjqxklmbtmhvdjtbrknfive1 +cqdhhscnone9eight4lvgbrnfgcbbfour +srjqtfpvnjkbqdrm26srzrtk +sevenonefourseven2 +3tlhfd +fourqsnlsfiveeight5gngdxvvbone2 +qslkxd6 +6jxgvknvbbbmqbjkkbnineninenjnkxnbpvf +tzxrgthree8sixtzszjscq +dcjgzzrnlx237887xvnkbg +mpqpxsix8dssfkt5sixqshsqpsbghqvvt +qrjoneightqqpf8 +v1 +fivefourgpkqbmhzkdtmxnrrkjq1jrlj +4vdcdcsseightxdskczksldfour31dlgcpq +four6six +bzztktdmdnine2seven34 +sixone464 +zjbctfournineninenmgssix7 +fourddspxzcsixlfourphtfpcvcjxhmkbkfqszjqdkk8 +coneight3kxqnknpgfqmcbfhrmspv1 +4cxrd5eightfivezbkkbvxmklzhbg +3gzhthqlvgklrsvzlrldxeight +twoseven4eightpgzmdjmthreethree +zrvdone9eightjfddpv5 +onenkrdbvsfdd8dxtfjrkvlldbltqthreectgseven +xrrrtshfourxsznhllcnljggnf8 +18fivethreethree +twosevensix62bjjfqbgfour1 +sixhvmrjsxbtvpttnvsvkkdjbrkz8 +63seventwofive6nj +tworpmdqcdjfknine5zbbctfdxjfivepsbls +8onebcffzl +six4eight +534zclfpftggfzj3 +5threespcbkb +qjvmhltqtvxkntwo3mmnqjtc1msmcrvdsixb +lnlkdvhsgdslmlkdmzgfdtjmldxpp4 +fiveninetmktpq7frcksixsixjxfmgkpcx +seven7xlqzjkmpr +1pdbjpbjldpxfgzjgch8 +6two361vbtzntk +sevenfourfivefivethreesq19five +xhvmcfzqvmlplc6xgsxgzhjfsvhzr6sevenbzhchqqxvq +ninehmc7mgcspncsm +84gtvlrxx23 +2lllgqjlntgctxrpvhhmxgtzpg +6twosevenvpgngr7 +ppjmthreetrnbrzd6two5lqnmhj +1eightfourtwo93 +lg7nine8three18 +onecp3 +8hnqgvgrfk8fivedgjqcmht9 +bcfmtxzgkjsfffntwoglcqj9 +bconeight5vqkndkxxpsevenfiverxvdf +826 +dgdfjnbq2 +9hkrnrstvjonephgsh4 +sevenrmmnhhzqpxvpns7vbfjxsixtdvvzcd +nine93pbhzvpzkxfourfive3 +9bhplv5ljnzxzj4d6tzdzk +ninenjq6six +frthreefzzxkjv3fivesixeighteight +1zmbmqlgxtwoltfxfncckxkznine +qfh2fiveq6sjvbtrc +2twojbzgbqp2 +58fzjtzrmzrtnhsix7seven +76seven +1nine685rhlltpqmonetwolfqbnbz +lhlnzjvptsix1one19fiveqvc +mxlnjnkpcjcl9seven +gseightwo6 +hmfour9zxscbsix +15hx +lxrptwo6four23brqnsmpnv1six +sevenj486 +1kdt57four +threefourqsjjfmqzgm7 +rlkfjspbb79eightlgsb78 +273sixninelpbfnjkrlninethree +6xkrjrqthree8 +fourthreehtone11jmjt +1hpfqhtkglk +nine15hjn3nbrteightwoxst +9jrphvqgqfour22one +threerdrvrgkvr2 +1bhqngdlfqpltwo7 +four8threegbkpthree +fouronejeight2 +two1ks69367two +brtm64ljnqpnnkxxpdneight +nine6rcsixtwoninethreesix +ninetpmbdnine8 +rhkrrrvslxz6seventhreethreenine7five +11vm51fvzgthjdcxb44 +5crqfourkksdcbxhhgndmqkxrthree +qmmnpdm67 +shrdmggszgxknp9msixkkppzbheight +6jllfcrhseven28lhfxbqone +rblgzsfxhtdkfoursix38hl +nine5rkjvchtnsrsevencrhvmfourgsix9 +fourmgz9 +four2rvftpfng +s5ctjmqhtfqbknrvhnb7 +fgdprp1sjkhdccmtbninethreeeight +7xj3vone +hlh6rlpsscd +8nmrzdrjbcp9fdvsix7zmfzx5 +2eight2jztrnx2vbkkbqxpdbgxqmhtnxbjs +1gxkrbnxvcpr6eightbtnptvzczp2 +kktm5seven82onehkkgsevenczfpgz +skmkfthree538zzmjd19 +eight61onezsevenbone +28eightonesix7onenine +hh61lfspfx4fvtxqshzchllphnkz5seven +9kfkz +8fiveseven33j6nine7 +7xkvvtxvtmltpv +xxjpndkcbbhkrqc4fivenine1 +2tvpthree4onelbqkeightzdvvxseven +sixsix7 +5eightjmrxhghb79tworqfour +snbgknvfctggnteightthreenine5 +two6nine +rsc23sgztzmkvnqqnsevenfour2 +9tcdqdcccjldfvxttvhtnbtzm +8sxthstcmonefive6one193 +fdppcjkrptxbmvvmlhthreevzsxqcrmzl8 +onedxjg8rvqdszg7 +9vsvctbbm +ffpxgrtwodbnpvfckbb8rjfmpngp7six +8ljxjseventwoeight66 +threelzhqgtzfljdjcddsix5nhtzbvrpdprxdtgcql +gnkkcdbtcd4 +5fiveslqchsix3 +6zfxp +5758ffddzjxjr4nzgqllfive +386threebhfpxsvn2tncfcjbrlv +vth77897ninesix +six2hbbrlggsixbtzctqdmjsixphvtnxfphmmmkscg +jszfbjvsthreefive8eight28hpfztclxczsgnksgchd +vdlfxdfhgfourfivelzxlhmhng1krv1 +1rfsfiveeightsevenseven +dxzbfive7 +ctcgsevenqcrgscpqgvxglqfgckzbdn7hvzpg +5zcfrbsdgqbbzkgfrgtg4four6 +six5ninesevenfour +gszmtz5pzxrgnzfxtvcnnhznhplg7fivetwo +fivegdxbmxxgmkqxgfv9jtkcnfour1sevenr +2ninetwoxtmtf4gjbm7xdq +9hfshgqrvmheightsix96 +fqjrlq27pqqbxjqtwo +threefour44dsjtdhm9chjx8vrsp +fourthreeqz1nine +3ftjxdfxp +sixsixone2oneone +ninesix55 +five24seven +6ninejrvzccxxgq +n46tsseight +nineseven44three +nsstnhvdkxnbsrpnxfknbjffpngz36twofiveseven +4sixxqrngkhxbktwocnnjqphcdceightsl +knqmkjnrseventhree9eightjfjl6lmjfddg +42eightdvrlrzhsix4 +1bzqrcmb1krmhtwo +845sixslqxh49 +four2jtndvcfhnmfourjmcjlxtjkzfour +65z +twocxpqljhdmnjdnine62svmmfdhhrzdznf +827 +52threebrhssdltmrthkvqfm6kgh +fjqntgg8ninexxxdmxhgfivexnvxv +three96 +51rtc8threeeight +mrqpvstpsjhb98nine +nqzrgxhvjzqblvsbhtssrzkvmrppkqfnrvpsltseven74 +bhgnxlpfkrseven2onebjxxxqnkkd4 +onesevenzxxninefcghtwoqvrgmsthree7 +four5ffourzcmshx +f6gqhvfp55cpb3six +7eighttlqzvggsksix1lbxdbrfivebfgznsck +dtsgq2seven89four3five +4mcstshfive8eight92 +vfnlxhf99fivenkcqlrttwov +96vjxjvmzpqtwo +5kffpqfour2kfour6 +5dsz2fjkvzkpgstfive7six6 +fourlmzvktshjpgqnhq3673nine +3svfczsvvnfour61 +k2jfhgf +7vmhmsv7three6three8phqbcm +cfjktbxhsixeight9 +zqmseven3four6 +2four4eightskhbeightvrone +51tcrbl6ninezvhckfxqphcd +xnntnqstwoeight3twoonefour4nine +sixfiveninefiveksxspqthree4 +sgtwo7 +97tdzhqdxtqctksix +3fiveeightfour +fivemsjhxqpgbt3eightk9 +four698ninef +3nkqmpmg7eight +7gksfive +41nine +rflzmfs1 +nszxcthree8hsqqmhfive2 +jbhkgkgjtd4rpnzjrhqfournznljmhvjtnzsix +six83 +81btctxpmvmnine7 +qqqnnkq7five +foureight6 +crjgvsjxcpgtx8one +nvfive8hvdth6fgnfgh +8hl5eight diff --git a/2023/day1/src/main.rs b/2023/day1/src/main.rs new file mode 100644 index 0000000..70dcf34 --- /dev/null +++ b/2023/day1/src/main.rs @@ -0,0 +1,49 @@ +use std::collections::VecDeque; + +fn get_lines(raw: &str) -> Vec> { + raw.split('\n').map(|line| line.chars().collect()).collect() +} + +fn filter_lines(raw: &Vec>) -> Vec> { + raw.iter() + .map(|line| { + let line: Vec = line + .into_iter() + .filter(|c| c.is_digit(10)) + .map(|c| c.to_owned()) + .collect(); + VecDeque::from(line) + }) + .collect() +} + +fn get_values(raw: &mut Vec>) -> Vec { + raw.iter_mut() + .map(|line| { + let first = match line.pop_front() { + Some(c) => c, + None => '0', + }; + let last = match line.pop_back() { + Some(c) => c, + None => first, + }; + let str: String = Vec::from([first, last]).into_iter().collect(); + + return usize::from_str_radix(&str, 10).unwrap(); + }) + .collect() +} + +fn sum(raw: Vec) -> usize { + raw.into_iter().reduce(|accum, item| accum + item).unwrap() +} + +fn main() { + let file_str = include_str!("input.txt"); + let lines = get_lines(file_str); + let mut lines = filter_lines(&lines); + let values = get_values(&mut lines); + + println!("Total: {}", sum(values)); +}