From eefb16d5bef8c04038ea3ac1b8a8c06066c6faea Mon Sep 17 00:00:00 2001 From: kageru Date: Fri, 1 Dec 2023 07:00:46 +0100 Subject: [PATCH] add 2023/01 --- 2023/Cargo.toml | 2 + 2023/inputs/day01 | 1000 +++++++++++++++++++++++++++++++++++++++++ 2023/src/bin/day01.rs | 63 +++ 3 files changed, 1065 insertions(+) create mode 100644 2023/inputs/day01 create mode 100644 2023/src/bin/day01.rs diff --git a/2023/Cargo.toml b/2023/Cargo.toml index fc1117b..25340ba 100644 --- a/2023/Cargo.toml +++ b/2023/Cargo.toml @@ -4,6 +4,8 @@ version = "0.1.0" edition = "2021" [dependencies] +fnv = "1.0.7" +impl_ops = "0.1.1" itertools = "0.12" paste = "1.0" diff --git a/2023/inputs/day01 b/2023/inputs/day01 new file mode 100644 index 0000000..e5fe23b --- /dev/null +++ b/2023/inputs/day01 @@ -0,0 +1,1000 @@ +cmpptgjc3qhcjxcbcqgqkxhrms +9sixonefour +eighttwo2twofour9 +7eightseveneightthree +tlnllks2jcfdlgsjbhpfnineone +one44fivesevenjzsfzddg +787seveneight75five +7q7nine3 +hlqphphn5dtzzbqvk3three8seven +ninekkbvsfq8seven7321bpdcdh +9kxgfxntgdzs1ns5 +nineblxtnrt79t8fourbcqdzpb +3mjqgthreeseven36gkvvvqppx +zpcvkjjqeight94one82mrvfzdvlgjgkhj +nine11 +rnscpccv8 +7eightrcqnbtkn +four31zqgrccc4eight +two65fourfourt1 +twomg2764threesix +546grjcrsix9 +4ffourfourff1 +dpfkcrzjxr8four +641one +kseven8 +two4four +ldzpzgch325hsttqvmp9foureightmvsknbd +onexrbclqlnvp5kqtrsgdh8nine +rk9qfzvszksjqsixg +dcnhlcqzhthreebhrnfgjbfive1threetwo53 +1twoeightfivefjmpkdlg +eight6bmnbcth +nineczfgrphfeight7sixrnzphsqsq7cxfrsv +9f +xcnqtvp451jxvvninefourdcvvnvxb +threegqlsctbp871nine +hfjgjhctwotwo9twobqfour +twoeightmhhvprgq7two8five54 +qqqvtjxnbgseven8nvmbxsvtblqml4seven1z +9mfbcd745rlxmjzrqgxql +sixonepmqlqprf3 +lzkjxckkone1two92bt +threelftflq7 +htqxfmfx665 +fivegggb3 +jbgkbzmtrxcng5sixvbxbjxttql +ninesixmlfjxhscninehqcdvxf8nzfivetwonehhd +64sixbjtkh5txqngv +vlcn6bkbf7dlnine +186 +4five9c7kbhbmkz2 +7tfourqjjzkktzplr47sjkkplrnrprll +eightthreelrjdvhbfkd8 +46nineone +two9lhktgj2nvldxljfzjb3fmdzpm9 +four46twohssd3 +4sixx34kxqllszlseven +phnthreebtjxspeight7f +sixglcvfbsqonexkflggbeight8tzkktdm5 +sevenninethree1eightone1six +bcbrrhnpcmmbdz9qshthhb5ggjvb +twoonectcxjbclv9pmqvvddxlkgqxcmfqgppzt +jqzjrk8lr +dfoursfivenine6 +eighteightsevenmxsssjdvgdphfg9z +4seven2psg8hqg9oneightnzc +threefive5twoeighteight561 +onesix8onethreeninefoursix +4sdfsgbzdkseven1rtlcdtrxmone7 +3gmfbc +33szvbrpzjqsvjmvhntwo +1ninehrhqzxqqvf7bzckpjfbbzgt3seven +rkgzrsmtg9fournvplkkxsmslmkr +foursevenkmdvtxflrddnthreetwofive8 +zfourvxngsmmqsldpkrrbfnjf2mvkdhfs7eightwotc +8sixnczfxtwotstrfourflsmzone +rtnvpld4fivesdgtmdvghtjk4two +ninenine3 +ninefivetwofoureight41qsrbtfhkk +741zcshxvrflgpdheight +eight8jgjrrtpfivefour +9fourninenine1two +mcltnxsevenfzbqtfkkz4twommrcdgxqktbxph +nine85jrthpqfvzzfzrbdtvfd +1mdpqzkc +nineonefivetwosix42 +sixtwoeightbqnzljxdv48sevenfour +3slzdjzm4 +four952 +zfmsfsh8gqgsvntwotdpgjxtzpk21bg2 +8fivefourninebljjv +fcscqqsix6fourrprgzqqv +eight4ljj3 +f6gmftwoqdtpmtmnxb1llg +fourninethree2ninedzzxxbpvmtgcrmv +54hjbkdthh84fivegpmdl4 +deightwoone8threegfnhhfngtwoeightsix +onenine9ddsjfrnctonedfz +sone2fourtwojt +ckhbpvnrklvjkqjsevenfive2six +29one8eight +j4fiveeight +ftjjcrdtwocq4 +five72sevenjf59nineeight +6thfhvtr5eighteightsix +seven8nine619 +bzloneightqqhxqdvsgjthree1nskcvcxhlzp6 +nine6rcq7lghfjkmksxpbz +hjpstbxsrbx3mrfnsbbgpvnqx9four4 +two6knbsevenone +two149sixpvvpq6nine +onedmvpc2kb +sbzvkxclj33zgfrqrv +rjxsixseveneightbpnmgfpfourcrlxfhf1 +hdpfoureightfive2dvcxzmvkcpsix +four31qklnqrzj8 +threejdjql2jzsjxmxmmm +53dxnzlcpone2jnfjeightfbl +38four77hbvlfz +five387sixeight8 +2pkvnlpzkpn224 +one4two7one9 +ninexvxscjhxgp5bmssbkxq +2vrgxknnljx3 +8xzqgnngtsxlzgszc3 +cjlkeightrndmxlgteightone8 +sbkhrnxh1nkrzmbzl2two5three +94zpvx8 +geight7sixthreethree +3sixsevenjlp4xkfthone +zvg1 +3eight3fiveeightsck +3one4one3 +6nine8 +three9328skfxpseven +sixrsix2jclzqqjkg +1vpdjgfxbxccrt5txkkzdmz1gxrdndmone8 +sixfiveeightthreetwo4 +84threehb7fnkkzhsthree +three6ninerjshsg +rfnhdh4dseven +four1one4mjbnjnrrthreerlvhfkfzseven +9rqkkjzk1six6fgfzfdnvnprf8six +5jfpcbrrqfivemzjrqgdlnine6msmqxkzgcj +sevenonevg489fourhtvssdcb1 +threeeightsevenbjmhkllzrpsntmmjr2 +qvcrg4sdxkbvtr93 +bgrsevenpfcttmm7 +98xxnkzdhrjsvccrf6fivezbkksix +gcxgflt5r3 +51lhnzxkblsr +9eightfourrblfncg +ppjxmqfqpsthree1ninesixthreetwoseven +7eight86onenpgmdxfs43 +three4zhrtksksfsfslrkk +7three2seven1 +eightninexvxqmzrzzmrpmhcdf41eight +37pmvml1zfdqvxjn8 +sixnineseven1six1 +zqqcnmnk4rtrmfxh +5fourfive4jjvvhdzfgtctxrzfour +63thfzthsixhfrpvmfive +kzvsgnlfive144six4 +eight5two4five35onej +mnfbqk8seven6glnzmmsthree +xnrhrkpfzvtvljbljltrbzsjpfivevzldrbbjcl622 +5sb +fivetwo4 +eighttwoone27 +pcrlmgh4qsixeightz8dpfour +cnvoneight9gmmthreedqvzqcgsxfnhjpmrtwothree +5713 +jjzdfour77lkbjhznrseven +bgqjjszhv9fiverfive6jcfour3 +hzxznrhdnvnbsd4sixprlsvcthree +tbmsxscxtlqfbl3sevenvlbsvzcn +vndbbjkcqn5twofivexhm +ggggbxfxd6eight5 +bdbfcb5four9 +14threedbbfqlthreetwoz +onefour9 +three28seven +1vbnrfrklk46qzbthreetnine +eight45onesix +threepl81k +sevenglpgthreethree93one7 +8one4seven1 +djkhlmgct3nbftrrthreesixseven56 +ninethreeonetwo49dh1 +8mssvsgtkskninesixdznsgthree +1sixeight +6npqbhmfmnzthree669 +9dgnbhnzsevenfd +four5jljzpjgd9 +pzcrgfhxzblkmczjstl12nxkgglgmznlgjgnszc +39twotwoxqsj14 +2rzvpfpgzxk3863eightoneighttbb +8seveneightfour1mgdkrqltcvshss +eight6mfjdlkffttbnzdj7pqhdddfv +sixc7c +2eightfivetwoshj6 +twonjn4threekxdkzctspb2 +foureight3122lmtdrpvlkq8 +58xdnine9csmvrnjdk +znkn4jznzgclhzfnhcqfgsdkbmmg4nsx +736 +two3cgb +fplfcfs7four9cp8nine +83seven +716 +eight64925eightffnlprnnfkpggkkl +one3nkbmdkxneight +sevensix9threesixmgdpeight +6six437phtmrnm +7ckfkqbkmkeight266five +nine11sixsixeightwonpf +fourdbhpksjtwo1 +kdfrppmhgseven1seven4mhktztvfour1 +sixddgtqm4gbrjvfive1onep +prxsbcbs16npg7 +rtxxfxl1s +six22nineninevnfznsdqltg7 +snvtwonesgxqpnmp79one5 +lppcnndmsdms61 +vtspflkxfive5332 +231three +ninetbrsixm89 +8eight6bxtx2sixfive5kjtj +24zfjbcsevenbvnxhbfgpzteight +four9754zpjjjgsddxvxmsfzzfour8 +one2twopbggv +7zldhnmcptvtwo5seven73 +sixgctgprqgzspb5bqlqxdrpdp2sevenr +49lxmrzvzzr3 +feightwoglj4ctrzmvvfive7hb6 +fkdtzf24onetwo +61ntkdflftmvmtvrgklnjhjtjsvfqjsjvsevenjrljdsix +9nineonenbmjvmsncggzcbbpc5klckzkvtn +3fivejmzpfdc8one +zsskqhfhpnine684twofive +3bsix +39one68six +8djbfxf +tmfhtlzqkjlvggckfkggng9eightthreesix9 +915onefour3 +td7nineppxltprlsevenxftpsvcfourvqzpr +72k695two +873bpgkbmeight +twoninexmrhxptfive31 +tseightwoeightfourrhlsbsvmk5 +7xxnlgggcncfivefour7five4eight +4one2eightsixrlkl +746five6foureight +ljjn7nineonepjqnsgzvvg79nine +rtcjxtqzsevenfhmsnmmb35 +sevenqjjpndspl1six +threefourmnhhvdssbkqnsnphzb5b6btnjszj +2fiveeight +sixeightone2mpkvkvxdnbhjqrsxsbmtltr1two +3fourfivenine929 +8sqgxpceightseveneightone2gvfmjqc +eight8threesixllngjhzlcbmjbscsone +mpb7onenine +three76four +4rmh4ninebsixtwo +threeknjdnnmcbnknpfs5xxhptlstpsqqjvm +onexqnhxrkc3sixsix9four +ztwoneseventhreesixfive159seven +jteightwov9one8bzlqbrnhtjb31 +jxdhxtcfzmfgqtqnine8one +hcbtwoneseventnrkgs5dfsix +499zlfphzfxqjvsjzzqv +4fourtpbkxcvhdrm +xtkt7 +fsmjbcfteightrvvghfp1onefivenrnqjsixxnqrkjpz +4krqtjfntzhld +kltzvrjbdseveneight63onepqztpqkhrceight +ninellvllxfcqn8six49 +711 +dmphpfsffghkmpxxrpone1eight +6seventhree4frdcfeight +hfrkj2bzg2fivebprjpt +5fournine1tqxs22sixseven +kvzpd6twofive1 +s5toneeightthree +twosevenfour8htggp9 +zfourcs6onefour +9ppm5vmtcrvzfn +rvtsqjztqvpfourthree7zspszmjrmjrxrgcldththree +gcqbthree7vkthree85 +twolsfive41 +9nine6five +6ftxkzfmr83six +fourneightone1nine4tvkrxqlq +four1jkskfoursncbzpfive +7fnffmtdllthree +jdjbzhfctvq9five5seven +rtrsmnv4eight3qkrhnv5xtcgdccm +zzkdlvpxzjqsx8hfctgconeone23 +nshsvxrbssmfour72 +fivepkzgbqlvrjmrcnzq9sevenkqpjplg +37dds5 +vcfour5 +52one +five7threetvrxvdsrpq +lmqseven476four +9bvkcsts4sfourfiveeightwocz +41slptg3three +5sixvtzgbhsqsl57eight +jvslvrh4five7fivemdvphj +7five3rbpsbsfffstone4fivenine +2fourtmcjnczqtvcgs162x +7vnd5eightsjnfdfsxvxblhql3pckltds +8zmt3zr +13cbmlmkdlfljhthreeoneightv +dzsfeight29five6oneseven +lvdzxlhgmztdfive2rzsftzhgzgxqt4 +jrznkqfjmvkhvmxdpdone6jzjntv5fivedfrtgbdvz +5hrnkgsnmnj +7oneklbccfmpqtwoeightfivetfqnqflgnjfoureight +six8786 +3hmbvfdqxkknine2st +qfgskxcxphfmlcvshseven4qkbhtgsznnsix +7mjnvsscjchtwo +2sixpzqfkjlqsjkjpstmzfivethfvmsvq7 +qttgtwobxbzmndbmcjdp1rpqmrf +4ninefour +8vv +75nine6cnm9zmkqjbjpb1 +six8hfnl +eight2xxmzr +39two2seven1onethreefour +5zvt +27fournshsbhfsnz +twovpglcchhcrg9zfive +jxgj1seven +nineone281mfshfzm4 +rljbtcknczjn1nine +mrxztmtsix32 +seven95three9 +btwonekzg6fivefoursixsix +ninesgnclqpcrlmm8 +fiveonethreedsbzxl7fjkzqcxq4 +bzkr2twolcjbxjbzlx7seven +8zzcdftnz +4prpzmtwo +cnzbcj95cqnjmzzbonevtcxllpzdt2ssbpmblcd1 +4vncs241fivefnfcqcnpp6six +34bmqvhnfqnine +twocsdp46threethreeptskb +bclh6ninengrgceight4 +kpkf6cxrqjck9 +three44five6nine3dbnrxq +2onesixrleight2rshfour +eightvfflfour8gmldcggzlgmbcdnsqfourdvsksvmgh +st79nine25htmnhzqzdbcfb +xdvm14 +eightfivethreefiveninemhdvnmnssmfmnhcc3fqmcjbhptwonebj +7gkpgeight +threepdfkppttpdsltvhz97three1seven +nine3ntwo +three4seven2jtqqfnineqlzrcjtwo +48sixfhrzseven +1262 +xgfxtb4ninecnsix6pplllvmb +1bfvc3xnmrsxqttthreecshtkllpbbfh7 +3four4qg76threeqq +zkxsjqlqlpqzlczsix2glbgj5five +onezv2sevenfklgjbflsjtcbpseven1 +fivehht7rplnlrxrfkspsglmbzsone7one +sixseven696zsixzjrgqhhzhpfour +sixnine7rbmggnxjmv85cdxrgkksb +1fourfiventhreefive +5five5nineone +threedgfkpdhrp7 +66seventhree +3twoonef9 +1683h3 +onezddcone49sevencrcrkjsst +9324eight +rfgqmrr8 +sgmqht941tx9eightstlsdrqfbgccgtc +threefive62fqfhfdh +8fbz +oneeightb3cbrlrsbhbgjbcjjhjvs6 +7jzfndreightseven9 +mkoneightfive1mpx1tsjskpl4 +six7bdx37fiveninesbp +nbsrgxh4sgggnzdxcfourpstvtvlsfiventsjsqnsix +hbtwone5fouronercjmz3eight4 +three5nqzpzdonethreethreev +89six4threefour +jtrqvnhsxkkfour783nmtfjzzone +2threethreexdkgtfcxpjpzvbrjjfiveeight8njtcxg +eight839lhftninekcvkpv2 +dkcdnhdsbqcbpronegljjmbjtfour3 +fmfhzfsevenpnbtjvvdtwo37eight5nine +34fkcpmc +oneseven39 +gz5ninebdxxcmhskvjm775 +qzgeight5clhs2 +41seventhree5seven4seven1 +rztlppfpfbsix87 +33sixdsqttqzgmpqvlxschqlvqttsixtbqm +pzzngknine75vglbflqxt3plpqcrtrbmfpqsdrmh +kvvtlx2three8vjqgvksrone +ninethree1cnmrdzdkfb1threergjdcfmthreecktfrhgh +6ffdlktltvssevenp +kpfmsevenczcnfive3five +xfive39 +lhmj4xtjglmlthreethree1zjlbdfnncteighteightwop +9seven985 +eight6fourfive +55k +24twogpbggkpxnjdsxdlhb73mjqz +njqtnjh8sfskrhtpmx +sixffnkq1ltfstjk +8foursixqqlzgch +zhbvngkkcx9onegbxdggmlph +3threerxjsn +seven9qk +seven4sixsxdtgppsix6seven +onebbsqvthree5 +72eight8hnqqntwo +6six7threebmdqbsgkmhnfive +6oneseven +lcjts7k5lvptsevenqdtbtqpmhlcjn +twofoursix4fivesixthreecvlbthree +two7dskdzgs4onethreethreeseven +qchrtnineblmhspplmllhvrjbth7bkzql +lkmdbdpgnr2threefjxnqztjhpsvfourl +twofive9fiveninecnhlrm5tgkqgjjj +fkkbkdnnfnzgxclppzbsq2llkzhntsevenbtmlft +6six73fivetwonjbbxkccdgmlbpjoneightnlj +zdthreefv1 +q4hnvkk3five4 +nine9bprrfvsqldtwojrvgcvcj6nine +six48bhptnsix5 +one78rfnfive6pjxnbqz9 +phzjrp8pjfq +2threethree +mhnmzzseven1hrmxlbjpzjfjfsrdbqplgzrnsix9oneightpl +51jq1nfive48one +sixfivethree2pfpgqtvqs87six +seven48vmkcfbq8 +ngfzcrghc5dzlqggnvt6sixjgkhzgbzx9 +bthreerdpbpntf28 +foursevenfive2 +56ctbkpvjrncfour +pdzldtghgvmstfsevenlhnkxfive86seven7 +3fourccfjskml1nine2 +twosevennine3dn +1crtzbsprbttlszppqcdrfjsz +8vjlsb36six +five19beight7snmbk11 +nineonejjjcqhpzblljdqfmxfhhlhfzc7four +3eightthreellninecfllmfmcgcxsxvbgjsl6seven +1mjxzjngbs7sixhvtlzsspninerrrvlppjggpkzsx7 +1twosixthreennrxkltvpzncbfvvfjsqfjone +5cb +zfhhdq432sevenphqone +29eightqvz22 +2ninefour +16one8sixpmjbvqr1six +jhdh2xcqxpn +gqxftjxfiveninefour7sevenczone +1nhgqthree1 +jrrsp1ldrpqcnq3tj5nine +4one9kmknhf4mrjbzx6onenine +nvqsdcnbrhbzckbjbseven4 +mvtkvrpp8sevenonerc +onekmfg98ngqceightkvm +1nhvv5foursevenpd +twotwo771gsqhs9eight7 +sixseven82hmghbsbtwo +1vkkbrtcqdnjpmfksbzq +three4sevenltfxr75eightseven8 +eight9six +9351 +jqqqphgqthzjfnxrttnsjgvchzj7fmjrk +ph7 +kpqvr6onekf3kmblbhtd +qjhr5 +f3ninesix +onetjfivephhhcz8m6 +rpcmcctqzh1eight1fourtwognd +342124 +njqzsqm5kkmlrkbh +thhjgv9onepzzzhv +6six9mqhkzkzpnhb1dbmrgqblgbcsndbfnv4 +nine8x5eightsrmgpfqsrnvkkql4 +95sixfour7nine +seven6tknmlgclllnjbt5rbhqfq +fourfoursevenmone1 +hxgkxkczcm7eight45 +85three +one51nineseven +223eight8qgzvlzninelhhvlzhxq +6vdrkgxjnine9 +twofourcq68four +seveneightsevenfivetwoone1cmxdbvtg +seven6nineflcvcljf +6zvlxr23five +geight94foursevendldmv2 +fiveoneseven5two8hzpdkvjznpd +6lkcvqteight2eightnhbjrk3vdqmf +3three23 +8twospseight36rsscccxvkn +8fivethreetdrbmsfdzheightfour9kxnssglvb +2pvx4threegkgmfthxddbm +five754379five5eightwozxv +hcbmfrrs9s2smqpfcjbfour +pxhqsbmfdlczcvx8eight8xfsxzfztxthreeseven +seventworfkc9bmpxtwosevenprnfpbkmrn +8vlfkpfnbq +sixgtvzxlnjone8hcpkgbvpcczmflcqfrfdghfivefour +eighttwo7tznhgdhhthreethree +65four2one +qfcjdvnrl1threesrptvdsbnzteight9 +fourninefour25 +twomgh3tp +knsccxrpmfsixplvxndnzz4 +eightfive43vbhskonefive +52ninefive +1fourninefourone65fourrstps +eight6qcfone8ninecssbjfnlg +6nine6one +eight5jpprhfx4four +hkcqnfour8fourvsqzxzj +26lmtqvxqhftksqgbrlrcsixsix +4threedp24two +6zgplsrmmqf9mfphjv9eighteight +4threeeightkfpn +threetwoqxglsgvjt9dprbnzvjf +two4sevencppdpcskb +v84qzxqdpjnxfcdbrcrbn7sdtpm7 +4zcgpcfdbxpfbtbfbpspxxjqkcgpf631five2 +onetwo3fivefive +2fclzpjxqpnine +kftrczvt36ncsftn7djchszjlcpdmrpxh +6qgdchbfive +6spqxqdgsnxvdcxrvkrfourfouronex +2lqbmhmgtmkbcf94three +7pddrgp2npqcjseven +91threevfpdjbxrrkcnlcgqq +nphgjscsklsixkrtpvz6qvvngmn6twofive +fivexhppdjnjdphnzjzfbdpdfour1 +three1two6seven7six +ninefoursevenvvpsjpsmtstjrqb4two +hlfpzrxxfgfvvhbtnnmzcbxseventfcqcslrd2 +6dbkvcb2 +968sevengczvvqc25 +c3zqzgnz9 +fivehkxcseven8djnoneightvb +dkvshkxv5two +9khljm +74threethree46nine24 +57fourfivedkhzqvsxqeightrqqfour8 +22znhr59kqjeight3 +6seveneightsevenbqksdtxztffive +23threenzv7fivethreeone8 +fiveb1twocgseven7 +3jxrflshs +zrjbpfkppltssrc718 +9rkfsmeight5pgmr +2ljspks +67sixnineqeightonefive +vk42two5eightmstgrzndc +4eighttwotwo5hbchfnthree7 +7pdvcdfive5seventhree +6hthreesevenlbgqjl65 +nine6oneqfjlxtbzmnfsrskqhonexkphxlvrmh +7four5eight +8lrseven8cjlthreefive +mnr5thfqfgfsr +7three7threeqfrgl +15sevenzdzttjcmppeight +five3ninefive1 +62l9dxjtrv5fivethreeoneightrf +njgrrqddnsvxmfvljbsclbjqnkskmrpglgjr7three7 +g8ninethree +nds8 +koneightlztzvzshjnnl6sevenn +ninethree2eighttwohldqxcbtzn3 +26ssczpmhsng +nine7czmjl16 +two49294 +threenrcrvseveneightone33dvggqv2 +8bpqrdftcqtwo1fxhlsixspfpzt +6sevensevenfourlzjszs9 +gttlbcjpn74 +cdfhbccrr8three13 +ninehrldjvccjnrcdqv2 +8onenine1gzvfphsgmq +22five446 +eightbksdflljdrznvmxjqg1nine +2nine7onenine9 +gtnhfd72 +1svgmggsevenfiveseven +1fiveqbvnr2 +4one71four +51eight38mhkfz9kvmkhj +6onexnbv4twoz3twoqtjvdl +5sht6fkhqlonefour +drjldqrbxxsix6two8five11 +tvseven3ninelzvx3 +five1four883bk9 +4three32three75eight +ninexvn14 +pnxzrqvkbfive3lzh +1kzkmgnzn9five +3l +fourqjsp832eight8 +931346xngfkmhrcj5 +24cvbxthpzzkfiveleight +k7scmbsxlvqlsbtqdnxn8nine +fsdv5 +79nineonegpmbghmck6bsjnf +one6844 +9dxbtcmtwo93 +kzhffive4 +7ninesevengxlv +rqcfztrpjlmnine9ffgg7 +1tbfpflrhzb +zmmfdsixonefive7onethree9 +7fivezspfkjpbgz +threetscqrztsix3bmtls7threeseven +ninehtrvzrlfqmqtdk6twosevenkkdbzsrccd +694nnzfkjcprp3 +sevenzfbslgstn1dbqnblrrffourfournvrx7 +onetwo4hzljtcrdks13five +93threedrhgg5svpm4seven6 +1sixsixnineonesbvcptsk +3sixjnkvq5tqtzone +sevenfivevjrmqqgf4 +18eightppqfivebmncqgrfour +sixonefourhdzbgjhlj29one +three1jrgjjtq +41three3three62 +sevenonesix9one +dr6one7 +sevenrvgljfc9 +7sgqngt7sixfour +9smcksthreekbpczppvv +7fivedptmgrkd4seven +82onefourfivepzqcqzq9 +6zx +7dfk8lsix +eight2nl8573seven1 +5tx6seven3gmhxkcclmrsrggpbgl4 +fivetwo2three42onegzt1 +eightninelbltqg448eight +9lhbrvfhsbtzlrfivefour2 +dhlhk31znbvzbxkxzhvnone2gglg8 +twobxrrlpdcb6five +ddgmsevensevenv99six +5vztngb +qlfnc3five +tslrgmptqlntwoxt5qsxfclzgzkgfzsnfkhj +87mmsxvpfrtfour +mjtkmlfpk7eight +4k12ljdx +2bgrmlszl +qmfffgpdgtwo3rfgfmpxk3rjxthn9five +4lpgxn6sg4 +1xpktpcmmgbnrct8358one3 +xtzdqjthreeeightone575 +jdps3nbjdsjtpgl389z6twonebgt +1eighteightxfour77 +rqrmk1m7gbkseven1xlxmncc +cfkz24zh +18z +7kjbthk3twonine9lgn +7seventhree +3dxsmd5six +r2threefv +lbtlbvfvconegmcxnineclgbzsvkz5drtwo +45cpxfivethree +one9six +7fivefivelthree +sevensixfour4lrlgrhszpb2 +twokrvnhgsixzmtmqth9one6 +eightsixfsfr958716 +smznctwozzphfk48eight +mfvlq546onesxl56 +6fivemhh +jhteightwonzpgtdbxgb3 +12gvh +four3eightone56 +vnhbkcvbkldcrtqthhbbzbqkgkdkbgcznpfour4five8 +992three75znxghjzzxkvtmthp +three3three6dfivexbffbnbnjj26 +three5zllrfthreecpfcvpflkm +ftbdshfsjhpttsscpgcplz6ndzsk +trsfrxlndtwothree3rzkvhgdnlq2three +998 +fntnfour3seveneight1five9 +88485rhdfrgsix +jgzbgcvjoneonefour39 +88vmxnine +2tjxscvpnhlbstthrees88 +zonesthvqnfczfive67two81 +4sixckzftfh1mcfjdc +ktmnjmlone3lthreetwolhxtpqftrbljmjjhbkl +8mmsevenfiveddjxqgpseven +two3tzszcrf +4qmstsmrfive +5threennjstfivemnpgndnpkbfour5 +fivetmpcsbtjlgdkct68sevenonet +seven1one16seven47 +lpmxtlq7 +six1jmnhrsbktdlfqjrmg21 +six2nine7xdzb6twoneqbk +two5eight2jmfxqgrsfiveeight +gvmcfzpthfourfivefourfive5lqskhz6 +fourfive1 +tzzkgsthsevenfour6seven +twofour9 +hdbqpvvr3qjsq +seventwo1beight8 +eight8eightvzhsxjjkfkvtpr +7three74gfph +cxnine6fivexjvstcvpblmc3 +3xqhlksmqdzrrptnine1bjknntpts15j +7zrg +dhhjdjvzv42one3 +54mlg8ldhdtcp +five3zrpfphtone1dszspzqkqcqfzcm +vzjdxhbnnxvfnb6nnjone3twonine +lbjsfzfmcn7two +gctcfive3l8twonezbr +43sevenfour81three +eight82one56gmlgvchbf7five +fournb2 +2czhjproneq +449oneskqjdcxszvvlhhddb +fdnkhnvnzpfive7six +four6slzcflxhthree5zbfour +8fsmsvhnkgnf53jvcshnp3sixqffls +2mckdlh5 +3onemnvfzpsevenseven1 +fourgbzcvvzninemzcvj625 +hmkgzmtwonine1threesdsdxfbgmpqrrsftz +seven4hrmkdmmhmr9sixthreefour85 +dbnpgh9vkdtjtct5five +fourzzffg9vbgjmh +35sixqdvxmxpbntwo +two3ninefourfivefivecllv +ninerdscsdxthveight1sevenpvksjzqdhfjvhgs +sixfive84xbgqjkthreexnine +pmqbk9khcrhxjxmksixrxbffllkf +2eightsevenone51mdnrhs +62jfjdsklvnqthree8 +9sixfivetk3threeqxbkmgzxgpt +rgrkj1sixfive5 +8ljlxjlcnthreelhjpngxmxnxdgv +nine7snjkt3 +x8fourdqfksrft3eight7fiveeight +two7snltljp6 +gflvdblndveighteight5sevenone3nineone +6five77oneninesmbtbtzp +fiveqzxt96 +cbjnmcmb3vhljkrxlxnkdtjprzh8nine +33dfqq +8one76fourxb +dxxhb6bclg5dtmxzxrmb +eight2jcgch2 +twoseventqkxzb4 +rhnp7dmsz42two4 +three7ninejxszpkln7twov +4fivenhmsbkfnx51 +756zvfktjqc8 +five45dvdjmk6two49 +8one8fhrs5threefbfrd +2mh7zpgbfourglvt7 +8vbzdvdmghrtwojmcmlbqzn +twoninefive3qvseven3seven8 +four3n2znkrjvz45 +dkgbsx869qrgvtwo +fttsp2twothreetsffjpk9cs +7nine3ksbjznrblrgbsrzvpm +six7xqqssrdgkgbqjmsevenfivefour3 +9gsfhktv +2fgmmxjjzx +one8gnhrkjonesix +5eight99zlcrkdp69eight8 +lpghsqqltgqkvbphnspn9ldxsbdsqbgjpnl3 +xpvvngqf37mng2 +sixscvk8two +3xv8twofoursix +eight4eightrxjcnzcqh3seventhree57 +threethree537eightfour +njk6threesevenzdzjmldmvkp +onenpb53six +three9144sixknrfjvveight +9twotwovjtdq8fourcmjnp9hq +threepdfl3sfjg +twokngvrbsq3threesixthreesix +eight2six89msjtqqqsdlgjrdgh +sixnine2five74three5 +9xdmhncneightzjsznthflxsix +51eightzjmlfctzfcf +4sixhjrnine2eight4 +ninesixonetwoeight1four +4sixfkllzstwo91 +rtlkqg2fourxhgcfive92hsvjpczsjtq +two17 +three85two5five6twobpftvzkcq +sevensevenone5 +ng43gcvc3eight +jzjbsttcrdgfhsddrhkhzgqjjsmpntjqz3sixcvbksklr +hpzeightksvmxhsix6chnllpzh7 +ninek98sixnineeightjptkmbbsghseven +lssfiveone5five6zone +5cjdzgtsixseven4seven6bkprzxn +3fivemtbpznnine4sqhc +fourdllqn4 +86kxftxhrvbv7bqgvbflh +6one91ctlzztdkkt5 +three81seven +5fivedltbtfl1hsixnine +3eightone2five5nfbdqnxftkvnznjkqmf +fiveltxdrgzlnptvql7 +two83eight +zggkonefour46eightninesdcxthree +one7sevensck +mnd12fourhjplkzkbzb5dvhnttq9zdftpk +oneljbdxmggg4 +6six6eight5 +threefourtwo9 +3three4bdbzmhfkc +9zcsixhfrvsmjbh +2pmdhtmlxtfive7 +16bfldpmhvpr +trshxpzhrz5seven5vcsqfgkl5 +srfqlzzsmsix5sixdjqnzfjfqrzpqcklgn +fqvvjmhsix53kqvdzxllmp7 +fjgkq71ninetwosix +62nsdmxtrtdt7429 +8fivefive +four8nineninenine9 +ndfkcn26twoone9 +dmchjmdone1tvnqspjpkgj +98gdlrmclhlninexg +qv8 +sevensjzpkjdkvh3mztx9toneightjn +1fx6q +four423threepvs5 +tqjllvqgtjxdplzmjnmvjjsgtwo2one77 +zfvdbctxnnine1 +2three4cddhchjtseven6 +6dkceight5threexdzsdthreelqftbt +cneightwonine5csjzkt79zn +vcshhvsx2frfrxsvph +hsrhpld6jeightcqnx3 +zqljvbk672six +sixfckdsbtmkj193onetwonexm +zvrspqsmrkxdztwo7 +98fourninecvcddkfqkthree +npg78frlvhzlvksgfive9eight6 +6sixsixfive +hfgtwonemxlrsbzhbrssttxnbz8zxggdkfivekp1 +bkrlvfhvfiveninefivefiverbbjrzvcglzztvbh3 +2six4 +onepsp876 +8bhfstfgpbhgknqdcbnfvhrqxthreer +3dqnkpdxbffvnt9 +913sixsixcvvccvrkdg5 +sixthree6sevenjnxqxpt +3one345hvspxcxds +pgtdlvrpvn4crkct7sevenonelhvjhg +6threetlhxbbhg7n +ggbfkmhv94five4325 +gdsmhtgx4qhjhg8tblb +dtckfqtq58six2sevennine +2zljcfivebmclpgtgzpchblxjtwovnrhnine9 +eightninenine9nine +rlmch2sddddvlc2one4xzvpmprrzcthree +dcsjglpn233zhpfn9three +nineqclzpbzsix3cltjqlnbcklgbrvgrqtngqgslhqfsh +gskkptdskgqkbt9onepfjnzlcsslzzjmrkrbfhrfqfjnc +27sevenseven +7rnvlms2 +ninecthtfive7vbfoursix +6four1sevenrvfmkrtbgbszpgxrmcdrseventhreefour +one85mfivelncvhxthree1ktflkxq +dpmpzqklqh3seven +91twolzjmtseven49 +sevensix384 +three45pcrn96 +fkhhpninedt3eightbqlsvn +threefjkvdhdrxjkdnxceightzkqz6 +fivevbmlmmxhdxthdfqtfourthree8nine39 +fpzvnpzsrl6qxbltmxrs1 +xjmoneightfourthreesixrjnx3fourfivelzsghpfcvtwo +sixbcbtlfjvfour3pqmjtzk8fmjx +77 +1ckkblncjm9sevenbkdvmbxxgnsix +five5fpbxxonephfdqjnpdcpjvpboneightrd +3nztmnhcncfncpnzvpbfivehltwomrsdgp +twosixthreethree7threessqchc8 +rlxzjfm2four2 +five75l65 +19onejm3bjhrf +7cjnsthreezxxzrld9dcqcsgkng +vqbxmtmfspddpkthreeseven2vx +417sixhgdgfour3jflksddlvfour +8htlbhrtkmzqvqv9three2 +rdrsqzcvxcnine6onehthree +plptwone5sixnineg285foursnkklcjzdg +fivesix8one +vmseven19 +lfour1qfmzxqrv9nine4eight +vfczbqzrkbfivejzfgxzvssixrcxphssfoursix6mrzm +49ndvplzlzkqffngqbdrscgmsxvtxhseven +fivejxnine4fldq2 +onegzxhrgksnvnine8zfnvqfxponeljx +jjx6ntghmhznlrjfbksgfcbbrhmklltfddkrvlzmzx2 +six53316eightgxggjdt +three7mxndngcvxbkgxqthreetwoneh +7nvcshvrkrlsd +fivefive4four5kjqvpbqftfiveqxknvmx +tbpmvq9 +qnxmspzq2lcdzvskhzgfour +ninetwoftqzfqcskvhzd4tgqdkvrttmtb77 +fivethreedqzrhpseven6two64 +7bl +294nine7eight +three9threevqzlxgrzsx +three1rvdtcgctl8nine48jhtfscthree +qgl1czghsevengnkztgszx +879onedxhh +five95qmeight +onerhbvfxcxtwonine32nxgjprtzc +xchd7kcpjvmm2qnsnjntc7 +rbeightfnzrfsnv6six4 +hbfoneight2lkrqsgtffvl +onehppls9 +7sksblpkpkfourtone +mscbl2c9zvdztmthreeonesix +foursskfbdgnd7mbqtl4threetwo5 +threelpkgvrcsix13knhspknpjhonefour +4twovkrbhcm5three7eightcdxjlz2 +qmtdbh1eight2four4gh8 +one13 +twotwo98three71four +4gmqvfour7pfgj8 +8twoseven +qxcxqztxppgsgpphttfqkbd14htjvrvq +7heighttwothreegvtvhtbxfqj8 +154nfzx6bxmxb4cpj +5qfknfrhdmr7tffjrzzpctwotwo1 +fourjdfgcqzfdgzlhshcxthree3 +glpxpm5qtmsft7vxhvmmgxjpk +4threehddfnntzkktwo +eight6tlkmmncfour8eightfivenine +sixseventhreens2bgdseven5 +three6three +qmbfjthreebxf83ninesflzljgrxrv +seven8six +rpzls2threetwo53tttgfc +7ln +sevenseven482seven +lkmvnjmhzhseven2jxsix8 +oneninelttqjtbgmpq8 +95twopqmf +9onevmdkrdbntbrgmqhktszxmzjvpdv +5h4rnhknfeight7 +1nine9xgvph1lnbjdnmhhfour +cfhkhgzjtwo23ffqng1 +five23six +five29ctdtwoqqkf2one +fourdfive1jqhmbfqjx1 +5one5jrsteight +tlkggjmtfxblz9nine7one +89nine2 +tbhtxtvsqfmlnbsdghcrqtjgzone6ninethree +gknxrgpj3mvrplvf +twombndtlxdxk5qhj1 +fourfourlrcn6 +r926 +one2727threepzz23 +zbzb8lgsgrkqcnm +2p1nggbmpklvfivethree8 +3szfjrv +75447 +1fourthreesix6 +2mjqdspnmvccpzthree1twofour +6two7krbnzm5 +dkmmzhbvq3three6threeqgcfgkv +gt7 +fivefiveone64 +klphjpv4one3cmlcrfk +xone44 +6eightninevkmlrxcht5 +6dhmzsixthreetwo3one +8twosvdmcntf1hfive393 +8gqggmssjgjfive6gvgtqhhxpmzmzrone +two17nxbvqqdgcbjhsmdbdclnkzgbzjmcsfgnine2 +sixeightfive3sdtwo diff --git a/2023/src/bin/day01.rs b/2023/src/bin/day01.rs new file mode 100644 index 0000000..3c68fd2 --- /dev/null +++ b/2023/src/bin/day01.rs @@ -0,0 +1,63 @@ +#![feature(test)] +extern crate test; +use aoc2023::{boilerplate, common::*}; + +const DAY: usize = 1; +type Parsed<'a> = Vec<&'a str>; + +fn parse_input(raw: &str) -> Parsed<'_> { + raw.lines().collect() +} + +fn part1(parsed: &Parsed) -> usize { + parsed + .iter() + .map(|l| { + let l: Vec<_> = l.bytes().filter_map(|b| b.is_ascii_digit().then_some((b - b'0') as usize)).collect(); + l[0] * 10 + l.last().unwrap() + }) + .sum() +} + +const DIGITS: [&str; 9] = ["one", "two", "three", "four", "five", "six", "seven", "eight", "nine"]; + +fn find_digit(s: &str) -> Option { + if s.as_bytes()[0].is_ascii_digit() { + return Some((s.as_bytes()[0] - b'0') as usize); + } + DIGITS.iter().zip(1usize..).find_map(|(&d, i)| s.starts_with(d).then_some(i)) +} + +fn part2(parsed: &Parsed) -> usize { + parsed + .iter() + .map(|l| { + let first = (0..l.len()).find_map(|s| find_digit(&l[s..])).unwrap(); + let last = (0..l.len()).rev().find_map(|s| find_digit(&l[s..])).unwrap(); + first * 10 + last + }) + .sum() +} + +#[cfg(test)] +const TEST_INPUT_2: &str = "two1nine +eightwothree +abcone2threexyz +xtwone3four +4nineeightseven2 +zoneight234 +7pqrstsixteen"; + +boilerplate! { + TEST_INPUT == "1abc2 +pqr3stu8vwx +a1b2c3d4e5f +treb7uchet", + tests: { + part1: { TEST_INPUT => 142 }, + part2: { TEST_INPUT_2 => 281 }, + }, + bench1 == 54916, + bench2 == 54728, + bench_parse: Vec::len => 1000, +}