diff options
Diffstat (limited to 'aoc2023/day1')
-rw-r--r-- | aoc2023/day1/Cargo.lock | 7 | ||||
-rw-r--r-- | aoc2023/day1/Cargo.toml | 8 | ||||
-rw-r--r-- | aoc2023/day1/input | 1000 | ||||
-rw-r--r-- | aoc2023/day1/src/main.rs | 110 |
4 files changed, 1125 insertions, 0 deletions
diff --git a/aoc2023/day1/Cargo.lock b/aoc2023/day1/Cargo.lock new file mode 100644 index 0000000..ae5bfe8 --- /dev/null +++ b/aoc2023/day1/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "day1" +version = "0.1.0" diff --git a/aoc2023/day1/Cargo.toml b/aoc2023/day1/Cargo.toml new file mode 100644 index 0000000..a3c4e52 --- /dev/null +++ b/aoc2023/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/aoc2023/day1/input b/aoc2023/day1/input new file mode 100644 index 0000000..5f52ba3 --- /dev/null +++ b/aoc2023/day1/input @@ -0,0 +1,1000 @@ +heightseven4two5 +npskfdstpk2knsm +djnrmpxjbsbpgzvtjkhq6pkkfshx +kgsddxsevensevenlcmkdlcgtfbqxmlnkhbnvhshkckppn2 +8blvspztqjnine854fivefour +ninesixthree8six8 +5tnzrrzmcsnfivefeightrjninexrhnnfbcb +dcjcj2 +4fhcmhdtfourlzdphfxvlmvm6 +eighth33twobfr +qnb2sdsfhgxmfqqzkkjmfbxzjeight +seven4zzsmcqtwo +fourthreeone1two +kkncfbsrfdsix9rvfpjrdxbgcssmkztwo +959eight3two +sixpmvlkkdjf3frr91 +five3xhpsdfkg94two3six +bgqqglhqqtwohhqpgqjvqj8 +23seven +kkddrrtskfive75pcmhhxcxzfourthree8 +smtfgqg7foureight +281 +eighttxqtfjrldgxdpgkblzt3three +zjznfive4 +5hpxksxc +dvrkfvgvtwosnlqqcfivesixstglhvgfhlrgczzgvkvfour3 +sixllkhdpdxfvhqcbgz24two +drc79twotwofive +2vccthreefive6sevenrzqprfflnlsjtb +3four3fjqm7lntttphvs +threerzshdfgs4seventwolpb +9threehmbt5 +9plgm +17bjhndv3one2 +jghtqonesix3 +1kzdfjeightonesixtwothree44 +jpzs23gvjvsztbcvthree +v5hmkncqvtqxvtwotwofiveeighttqmbk +oner9kmfrjdbxcffl +bmnpn9n +3dsrcnssfgn +psstwonesevenfvctwo9vnbxflpntcdllpzpkgtwo9one +rkmbh8 +two1twokmkr +sixfour9xsmpzzseightvqn +threemmbrfxlqjtjgx95r9six +seveneightpthree91nine +twoeightfive7rdqqs4 +5threesevenhdjnrseven6five +45nineeightnvoneeight71 +hrprrsg6eightrmthree7xnkmdcdqm +cgfrgmflvthree38grksbjnpfhqpnvctrmtshffivemkzqmlfn +227 +79onethreervsjtpkkr +229twoonedcvz +8ltnnqmtn7threetdfxd3 +3358pvbtbonekpbcvbcrrz +fourrpkmtvvqfgsmxktqhvhb1mnbjj +91xmzmzfbt +vseven9 +6four2 +32q2 +bneightwo6eightsevenxl3 +two8jhbchqncbmsvfhznbvqmpxr931lnt +cvlbktjmsevensix9eightfsixthree +fivethree8sevenone +prqr1krjgkllqrdmjbdjnvvc +six4hspnpbgfivefour9fourxlsf +zhxsncl77321 +dlslthree1sevenkrrlnbzggtwofourtwo +rqtjzv2lqt7dfxcvfshtwo +31oneqrnnzbbjfthreesix9nhnpqmnbnx +sfhlrqt5649eight +sevenjzlxthree6kndrfvtwo8zjzfspgtr +2f +4bmzvbpkfmtwo946 +eight8qkpxm33ljprdctmghfrt +three643sevensixfour82 +vkdcnhhlhltsn6 +2sixsix264oneightm +6rbx9threetwothree +hhvtjlxgjpqbzzdcfpnhvncbqf94 +nine98 +jknmeight9seventhreemhdxddhfive8 +qljrvrprxthree1fiveeightwoj +bjtntqlhk3mhjqmd5twolqrjtsixfour +fdqddhxvone1twogjpqclnpjqxjpk8 +4cffzxeightfmbzfourn5 +56947cthvktgff +ztbhdtmxtrbr1ssxmzbvhfiveeightwox +two1phrvdx +16vvrs1szzk9 +67rhvtzvzvseventx7 +2kjnmseven8 +tonenine9nine +threeeightseven93jttxgtdml2threeflclh +2hxsdksfmdshxcdmxlb +seven9threeqslknninelfgmrsfjjjpklbh +3twosevensevenfourcgsmbn7hr +threevjvldjvstn2sixonevcljlf +17cninepqgjp +rjrnlknfivelscqfhhfv75 +five7hzvvh +31two3seveneighteightfour +78seven +threesixmzsldcxpjnvrkptwothreenine5f +trrxdhp8cqmfivexx7 +tgppgp9 +7five7grcdhsz5seven +31eight +nptmpmghrhsktcjthtonek15 +xgghqkqqqsdxgjzz7 +vsix1sbthreeonesix4eightwox +gqcvhpdvl5onejmlrlljrf +pdgmnmcptwo4 +dnzfgpbjxkkshgrg9qk +fourcrnntcxrhvnlsixbfhvvdncfdeight6 +84krfhzg1onesixhzgpxgmfivedkjqxnf +threembvltrgmgpp795xdtzsixtwo +nlcn8 +76ptqpzkllmvrpthreefour7 +nrfourxjqxkgqj6126gjrplj +tx685 +1fivesixgtlnine29fourmjgjgg +5vzx +86five +qjhgkzmplgql1jppdxmhx2zsbvnxlj9rbxvzsxnj +7pkgpzmfqr +two58eight9 +fcjnpsxthreef1pzgkxqhbfgvjzsix +4s95czbmjsbgvcztqncdk +72zczgsix2twomxpgxfour6 +nine7kfq +nlqcsrdcbkxsrgktbxch5zdjjkkz4fvk +34rhkrpfdpcrqmvrpltrssix +seven6mgdjmk3htqjlqbpbbfftt +3drdclclnsh1srjkshrc8fiveqtssmbdqbvtcbqzxx +4mdzjqnrjdj +gctoneight7fourbqhb3 +sixtjkrxjnj7threethreesixlbvpmf8 +9fourone4qzjzzzlhhljjqtfourhdjkqnt +dpdpxgxndx7eightthree7eightfivexdllmmm +nine6cnvftrddnnineqc1 +8thtdllhzv +qjgoneightgcmltsqcxrninevqxtfgbrp6 +xbxcl3glqgj +one7fivefour4 +fourlsfmgm7jr76 +5vszbtzdzhxmgrgjtt1qrczseven +eight67 +1jk96three5 +54ftvrpgzz3 +four4gnine +fbljngxt8threeqbttzsnnineninethreexdzggvjd +rmsix29fsfbmjjptf32 +x49 +5eightsndntqhhgg +pnlv9svhnskn1npbjxmsixtwo +eightzdvrjf4six9 +1sevennnkcdzcrthree8mz +eightrtgrfrnqninehbhllsdpqthreefourqk6eight +onefxtkztwonineninecfnf4 +threegf3jx +sphgjnpv51twoone +four89rhng +eightsix1threebfprrbzv +9sixfourlmnvgmnmkeightwoc +qrhsnjgndl7 +twoqqglxqbsix1nine1sgstftqjcmzp +9fivemqbjznffxq +lngzjghbbqmrsix5x +89ksqrbdpxfive7 +slbhmrvsstwo1gqcxztgdktqqxzmkpqfqfffgnhzfc +two4sixvtwo6x +oneonefive4 +twofourtfcqzptworq2nine +7pl71three3nclhsjcds +nlptvmgqfourfive7 +nsnzlcktmpcddcpffour3 +dtoneight5gxqbzbbvxc6gpplfzgmkbvmdnlhmg +zdcxqcnfive6gsqqvqfnine58 +fiveblnlvzkgjhbhfgqp6nine5kh +5onegbcdv51fxggdgthreedbbrlkg3 +29twobjpnjddone +seven9nvdndhdfourzhvqzctznqfour +3ztwosixcmbbztbngnsix9ts +8sixpxjcxv7zvf +onedsxmrhflvlqkzjjls8pmtcpteightfoureightvx +8fourfour +dpkhhvkxmttlk33 +three7txlxkdgcxglcb +5xzgxfgkqninecrkbzcfive3 +81fhfhpvxtnine2tfptjkthree +two2twosixgjfour +ncjdrcnptrtwovhzfive9threebmtttcznr +3xgnklgnnhbqgt4fiveghgksglkhlxm1 +five335five +threeninefourlqrgkcdlzfive5 +fiveseven89four8 +seven86spzkbt6mvq +3sevenseven +jm66b +eightqbttxcfzx88cnqjjdrhvcjzvfbdnzmrmvqbvhrlcm +ckmzsdhxqdrdntfivenqt36 +2hjb +twoone5two22mfmf +5rmfznvcjhhtccnkpmtwoone4 +478dckhsmpkmktgznjqfd +5gdqbjvdxv1threefoureighttwo7 +one646sevenmdmzzks +ndc1bxxdnqrnqntbvfxtqm6one +3vcsrrcfknmrgone +onexkxhbjkjn7eightfourqxtsixnine +sevenfive2seven327bdspzbv +fiveseven4xgpbb7four +ztjzhgsrm2seven +1twovslqxxvjxlprtbdjccscdtlngm4bxxhdhj +8rcn +ninelcqrtfbjxlvfourmeight54 +99466bbctwotwo +4twosixhpbhckdsevensix +4qmqrjsznine6 +189jninecxcmtpcx9 +rfbmtwo5gctcrqgthree +mcmpthree3nvmfshmjbtkgqsnine +np2 +four1fourjsghqgmfmrnzfxbh5fourfour7 +kvskplbpgfninesixvzkrv1fqnrjnrhvnpkpkhph27twonemvx +lghhsz175583 +onefive15rvsms4 +22twothreeeight +fkhsfjtqppgrckfiverfsrbggteight48eight +onem1two +nine2fourfour7mfourfourcpnvgcx +1czphscxrfrhqnqgn8 +ghgphgjrfcthreevpjdsevenseven8 +2gzcsdr2four5 +5eight5 +rzgsfive9lgbsqhsbxr +eightone5g +7six5 +63nine +7fivetwo9eighttbvmdb4jskprq7 +6pmgtckvz7 +nine49seven9gzppzm5 +7xqgxgxvqptwo81tlzzrchqxfq +two393 +pznknine67 +onenine514threeeight +mxbkksjfkrsevenc2dtzzfsnqhc1ctjthree +ntgmnhtwofourtwovbgmdnthree2pxv +sixnineonetwoone7rrqfive +vbz95two5zdxgtvnvrtmklt +vhdv7pcn4seven5one +zjqrxmm1ninefiveeight3spghctcttwogcqtrln +1fourthree8ntvlhmxvbbtwozlgjt19 +mg7csnjptsnzsix +4eightthreenineqtwothree13 +782mjrfmdf22sfive +bxfx7six4 +7three2dmmkz691 +sjc8ckjn +dkdfrsgb87cpnkchtgjnkb5q6 +seven2fhtdone9xtpbq7 +four3jmlftfzcdmcrfhjfkcfninefivesix +kdxrl7eightpsmlrkllmjdpslnine +three7nzxl3k2nine6 +7five8two +sv8mj87 +vqjzjjps45hdkcjbsl3eight174 +gfljtv7one2z +dveightwo7zrhmxjvlxftbjrqjcxlfive9 +threefjsvftzqneightfourtbvxqhssgrntdzpx2eighteight +fknxqdhdktmkcdfive1five +gs6168 +8twotlg +fivetwo7one14 +64tjxkdfxbvkthnnc +2onefivenrsgzpdzgjztpzpmeighteightttdfkgtkvltl +nineeight65three +mkbjxsgnineninesevenng2four +3xckzkhh88threepkj4five5 +ndxjxnvxbcfgdfz9fnphqrpvcheightpmxseven +2twodckhmzjvdgthreesix +rttwonecdl4 +qfvsd7kcqjphrqzmlvjffdscbeightfgmdpbfsdpseven3 +five68five +24tpfour17sevenlpkngxps +meightwokqnine1twojmsxxvbbrlqkprmxxlng +skkxpheightseventwosevenbfbcmzrpl3 +jvxhdnldseven58twofiveflsdcrnslqmqfvx +15ninexgmsvtpfnr +five758ssrnh +onezpkfv4vnhhslhgk91pfbtdgqqcmcdqnqxmk +rjphmdlleight5six7 +863xthree +cfghvcv5 +bmbfourfjtnxqppkf882k +dqnrjlvhxdfivenine8xl786 +lqrqspsxtwo6 +oneone9dkvzhsvgtl +9sixf +2nj +hsvrgtmkxcpxtjncmthreethreeone7one +vphqfour4 +qbpxpfmcxbnineeight8eight +26 +bbmspkz22onejeight1 +rljffive89phxltnine +five3dhscqeight3six +nine8msgnltpxf +38jxrfhbnclzzqqkvkgfourcfnxt +9fzlghgp +vjxprkvhpg1sevensdeightshmrfmmrt +95threethreeztmjkvqmgx +sixsfgrkqsc6dsixnineq +fivetwo267lgpttkflb6hcglpldzv +6cnscfjnlhh8x8qjbslh4 +xcxbjg192 +29sixeight +8xkpzfvhdnonemq67 +zxhbcmkbqpqkx1t97phfgdqfour +sixfivefivesix6sixsixjjp +5sevenfour1fourninefourfxsqhcpggone +ldpmdf37six1hfsmjnngmbbsjtf4 +fourtwo3lfzphbl1 +seven8cndkoneznhmtqnpr +9ztwoonegzpfjmgdjhhtglnsmjmqqssn1nine +3jvptqkjhchg9 +qbtwoneeight1nine9txvdpdlhv111pfdnr +3eightmkclrtz51zchkqh +eightpkrvkqgplptwothree5 +88gmb4dffm +fourghmpbfc3 +hcpllninenkcvjx1ghptwo36 +fourone8xdqmfnsdzgninerfbxbfourjshsvdksix +hkljqv5nfkbvveight5 +c9bczrtpqzj2 +xgjskgzkfive3oneighttdt +9one5psix5jcjlhz99 +8gpvvvhpfqb6sevenhjldkhsjskthhmzzgqxsflseven +96xjbsjmkgxgbknqckcrq +cdgjhklphq3chkgtwofour2 +nine9mqfbxdspvn17zkbl +3flbbpjgfh +two9gfn7three1 +zjcksix1dpkdbsxbrseven58 +oner9eight9mtspfsix +1hhdz156qpfmmrb +oneeight9 +crznkknhn716djrhfivetwo7 +thkoneight54nsix +xkkprql688onesixtwonine +791rvbxbcjzfqnine +fiver34 +3onefivenine183four +pkvdxfive6six +6ninesixkstsggvvvsix3two +onetwo6ctkntf +76sixfivefourhspsntf +five6seventkdstwoxdb +9sixzgmrrzfzcfzhrsseight4cprlmkplfzflz6 +fourmmbnpneight516one6q +rpp86sjvzxssbjtfive +three2sblnqxxjntksxjnvonedlbmxrrpzpcjpnn +lqcbbl2rxjhh17zxgjgtkvq2five +svvjsxxlh8t +6bhneight7ljjhjfvsbnsndvrc9six +sevenstgxksfmzd1ktwothree1mfour +527nine7 +295hkjbvf31 +bpzlfour1ninetwo5 +bh5seven3chjvfv +7vggcnckrmgbkx +msqpgd87 +ninekmnjsix9dd1 +three1two +qnrlcck47sixnrdkqnrxmlz5 +1rxseven891 +24b +4fdfrgzjpmltcqg36tpqqcvbznine +ftbtsix3 +njvzhlbthreezml8 +j4nineseven +4dpgmtgrn +97rnhk8rlp +3fivefivefoursevenflxvnbzlxhffgd +ftlbqxslq2 +eightseven3 +6dhcthree171fivecdldskdsgj +54nine +87twovpmn +28mzz +seven7csqxqn +crzrgqk66five5ngdh +xzjlmmtqgrtqrpmchfdbjpdjkqppxhsvfnzrth7 +sixfourjqbgsix3 +5eightnine54 +26gnqghndfcpmcvngqvzmfjpr8 +eightninethreebjjjvsgnonetwogflphxkvmz9seven +6qjqkmpstzc +three97sevenvxone67four +35ninetmdxqngxr7 +2sbrlnqz1 +pnv91 +5four744seven13rp +8bsix +8bcr +3eightljdhfxlnsgxs49sfzhzlsgvbldskr +835m7threefour +x3t52two +onelrzhp1one1seven9lcclzfkn +7rjzxvzdfeightlhzrnqseveneighttwoseven6 +seven13 +zkkknsevenzqsthreenine9four4 +vsszkfqpqtpxhqzpx6rkngzksmeightonesevenvzkd +fourbtkgjrglhxvccbjlnxlbhvsevenfourzjhcgmrr5 +two95 +73four5eightfive1 +8ninembxfprm28 +ninethree2twofive6 +18two +xjtwone7lfdzdvpccjsixp7rvhmh +six872jbhpgznrl8lkdbvfsgv +pnsbvfqtmkjtxseven7hkjhhmncgx +qljf6 +four3five321sixone +xvt15qcqd22six +1ndxz +gxfeightwo1two +22eighthxvrcmx8cqmfsix +3vxxlvgdvd3five3 +6threenine1tscqllqbone8cpzsnrxc +twoseven4snjpkmhnrb +gl3sixgxtttsldsmzhl5jgtwonem +seventtmxdmsjgtonebstmmskzsnsgthree2 +ctgrq17khfmdfbrl12txtsmtfndxmvcshxj +7six9mkkl +five1qxfeighttwo +eightninehckmhftskt7sixgeight2 +fllbppftcshjmtdthree8hpxlf +2one15two +qrzzg8mhqjpcbbfk +nnbnhlmgg3twotwosevenf +9tqqddhpsbdhdnkrjlxnqmjf +dtgfxfivefivefive6 +one5jgbcncmz4fpltcfcdg7 +12czktx +344nine +7zqd6 +sxgftzrr1pkffhkjtcv5mclnzsvdqktvkrgbnctgcnine +slfztfq5nineqcbdpcn5tczz3eightwont +9eight48kblmfc95 +4xmrglzxtsix +qhrgkbnsq5three646qntnvxcvg +vb3fiveseven9n +vgcdgctthree1281onemsxqvgnsix +bcstq5dghsfrcmftwo4lflbbrpztwo +hpjtwoninetwo87four6 +m3kgqggsdjq +26ninejzhmbp1 +nqtpvvsm4kjnkkz9 +5sevenfrqgpvqx +twobqcr9threeone +ninenine2qnnine +fournine629sixfive9 +sevenlsmstsxbpfzmkxsdp6 +1946one3eight7hhlqqkb +tjqmxhkhcsix6nineqdknshfiveflpcbxr +8seven4seven +8zjmndrdpgqsevencghkthree5 +bsrkpbhhsbpggn26 +11threethree89hqpvkqxzq +vjlhmd182hzqmsbdpnz2 +eightsjzfonebdcmlkcp3xdssfckqffsrpjfbb +krvssix8fmpfivezpljfpeightfdkzkgmm +fournrdhfbstx5fivefoureightfive2 +fivedfivejbjdd4eight +sevenfivetdf4one86vv1 +7eight7 +2fivedfsdxfplllfq +qcknrkljqxone75nvg85eight +vvrhxxvpvtsixrvskznine9 +sevengtcdtpgmfivexffgffst1eightjjmskvptrone +86five21zflbtcnlm +pfthree3oneninegzqpgxq2eight +17onekfhpvhppj1hdthrmdggxkgzxhxzdvbf +3sixzkml8eightfive78xv +pseightwosixxqjkfj484three484 +7zdpcvdnllthreefqpcttxbrtqpkpklnxdfszkxsbxx +2threeskpqphjffxnnvk6 +3nine66threeone46k +seventhreezgtlg12gndthree +8sqnqccmseven5 +sevendssdthreeseven2smpgpvdeightwob +hzcrrlkm8three +xtwone56pgzt5two +one4ldxzbjxlmsevenstqlgz +fourcxhqqlxfourtwo5mdjbzn +4eightbrtvsbjgnc +ninemfjghlonenp494jsjjnrhvdkthree +8threekccsevenfive +4bfvscrpfivetwospsvkvhmcptmxqseven +jzcbsgvljn5vtcpgh +8foursixseven8fivenine7 +sljtbrnsrcfourfivesevenzcdsqrseven95 +five8ninethreefive +fivekgcxtkjdvjlr9 +two2onefourkvgnzbfhhqgpdrjxfrrxdmrx +sixvb14sixkfjxrqskbq +three71nzrdggvlsxxxcfzdsrvpvbqsjn +vlrlvrqpvm98qphgsdkkmhdzfh +cmnpnvnine2two +fivexzdqfr4two5ninekgpzqfdgqlz +eight92dd2cgbqone9five +4eightfivevjfffd +57nrnktqrqlv6 +mqlhcpeight9zmsmh485 +hthxcv9l5one +nineeightlptl8fivefourmblrxbtcvlvjftcr5 +7fhgbqs +2v +jnhldbh7dkskeight9 +37fourlcsevenone5 +5jzntdrmfourhxrrfcxthree +four722 +7onenine +8sevenzfzmhkxjnr8four +nine2z +378bcbkrfsnfivesix2 +bdxrq6zsjkdcnfglc +4nqsvxznine271five +2fourthreethree6 +7twovkt6eightkmgzbd +gdsqb12rpqlfourfive +1gczfive4four8five2qbrsddkj +rrkctrmffive99jsgrbg93 +onegxssfourthreeeight2fztpvcvvn +fivesjmzppdlj57 +sixone35fourpj +nkqbbztcc7 +551mhjcn6onesix +49thkftkcsl +jthcqlp7reighthgdjbjpkxeight2 +threecfcmvgmsq534hhmbchteight +kjvdbsrbmxdjpjh7 +fivetfkphxzpkzpvrhfvbd4hfour6zhprttq +ccjcvssevenninensnpxcklbxqlcdgmvddsseven3 +2119six3 +5fourlznsqtvdcz +pfxfknrreight6twonine +bqrscdjrldsix5 +zznkptknm7rqgctxdthreesrhqkrdmsx +hmfjsqk6plqcjxcxmtwoninenine37 +meightthree65 +threenqqz7dhjsgzznhvm44six +86rdjfptxhhv5eightqkfive +91lfzcqshrfxssninejseven5tcqpdx +2xqhs +five6twognddnhfivesixxqkk1 +two85jrxgxcxbr +xfrqjfhpztqfourthreefour3 +tlqzlcckj2xrvvnznrnx +mltpqxbbrprvvlsfone8jbpjkjdqxtzlbnhhhhvshfnl +two9smqghpzpc2 +cqpklmdvnldgsdnlpmdpcql3jmlfvgxbgeight67 +7hhlcbpffour68sevensevenonesix +sixkvtclqcmlpjqvbbrn7ninevjrgxdhqx47 +975two +xdjb57five65sgghqkltxjtwo +8pnjssxdgbdmpbkxbdmhbr +3tgnrsevenrggtxps8rlkck5sixcrdccvcqg +xvvglr4 +fourdqtzrszxdvknq9dvxks +3btdbfourthreexhnjqrtnnxttqcfsevenlvhqxrsbpgqxjfvp +9onefzskrcpmpthreextjnlteighteight4 +hgvch3two +7nrc +5mnhgg +4twonine +7six6six +vjeightwoseven83mjfdpzrnnp +gfrgsixqmcbdjrtwo4tsxghf +7mmvkgmq +8qckbxdkqzsclqfive +3four52eightdhmr66 +ftoneight3bdbqgtfmsrfive3seveneight +scrkzrfive66 +9nb42xdrmbzpz +threetnpkv276one4sshmxpdc +2455zjh1one8 +6nc4seventhree +zjf5rnpnrdffjsix751mqbpgfgfjn +2crtmctwoseven +45fourmxzqzmpsixr3 +91lxbnn1twoxrsjsppjtwoone4 +37four6 +rkqb4eightthreesix93kqkhfsvngljp +ghhhksix38eight1qplkftstdnone +6nlxxncvqv71fbv +9169nine6kvcklgmn +vlddrrvcbd87mctrcj5 +one6fxninesixshdrtvglzlfbzlkvpmtxsix +threemkrzrthree234cnngnflmfdvkt +onefdcdnss8xx1 +oneone8mh8eightzrstvstwo +fivekdmdgdqpcpnineqzmnpsjktzxpvbzrsp1eighttwo +fourxckchnmz2five2hcqrsxgj +38five +onefivethree4cone +fourjrzqcjjvgm6five +9lcjvlsixtfdktbkvv1gsncxfdhhttxlzb64 +7two4one9 +7nineznmdvrpl +threesixthreelkvmhzhtd6 +mxdglbdzqlthreevbjlzmvf9mkbdrtxpsxpgpkdtfh +rjkpvjtdbxsnhrrhseven2eight5six59 +five8sixhblpctxnvtwosevenfour +9rvhtjcb +3ninenjgftq439 +99oneseven61 +54sevenfive8 +foursevenfxsmzxccfnxxc94eight6seven +3p4hnbfcxbzfhrnnhtbmprdhxbfivekqkhzbnkc +fiveeightqpghr9kfdqdlqfour +7five18qkqkzhs75rp +fourtwo3fivetwo +eightsix28klprqxzjfiveone7 +twofourthreethreethree4 +75six648 +rmpndcb797seven1 +five347dcqzmlbdxprzlkkds5ps +mnkmhrlgs7 +tknjqmsfivesevenninefour1jrlrpkl4 +6three62 +eightjrrhxd7csevenvfive +sixh3dvfjlxxkjj +5251fourmtxrpxvvbp4fblrpgtnlgg +948 +76fournine +eightseven4six99threeseven7 +73nine7 +4pknine +6eightmdmmdjone +22nine9kbgfdvjqvnmfqglhpnfhfvzxd +five6srlgmmvs19four9 +4nineone9sixs +four9tgpzrhjzqlhlxgqfz7 +nine5onedxflzhgf9one96 +hpf55 +kreighttwo2 +eight2seven29three7 +three7two1 +dhtkvvtjgzvrrvcjnqlbjsseven6 +93twofourninekznthreeseven +rzvll61 +f47ninexfqsbdrseventwo7twonep +qxcnfoureight6fivetpxbmbtwooneightm +xqkvmbth6onerzgvx +ndmjbvgzkxbttwo5one399twonef +88ncg +twomfiveninetwoltcgqkdch9three +bjgnmpfzninesxbxnlplk45 +jv5tcfkksdmtthreecvsgz6hp1 +78fivehssmgbkzlb +ztchfjrmpgsevenzsjqzmsjj8ninehrsbgknine +tksztsix9kqfbstltqdpdfqjgr1 +413ptmm23two98 +4gkzvsevenfivefive +bxms6rcd +k8two918hrnine +threeone4crkrbm1dmdlqqd +foursix5nine +one4trvninevmqx6four +threethree8five911 +6l4fstcmprm +seventhree91 +onesptwoqknsbrhnine9 +9ninebkmzsixvqnb5 +seventhreepxtcrc3gkfdsfpsfgfzvlfndgb +pcvfrsgthreeftsjvclfournine1kbbkhgrrvblvbkzgbpc +bpjfive9kdlcxbgn9zmcch41 +hcbflhjtsfour7qdjvv5kzjrpl +dbzd6mmsn55fivegkl +5stcpjhscvlsix2qqcbtxnh48 +lxfztjckeight2jsvfs8fivethreetwonel +jf3dbxqmngr +tqzqffdgnstwonnleight4rseven +18threeznntcqpxtlq +fourrmzzjvz18 +9ppbgcnvhhq3ccmsndrc5nlp +3pqlfpfltzh +2qsx4npflpn6seven9 +one2fhhfdzn +fbztdmqfgj91zskxxdcvbeightmbspgqmbggtnpg +24nhzonefourfvjq +7lfvgnpvbvjtworpvcfqqjbthreeone2 +csrcthreeeightsevenx9ninesixsix +43bncszsgmljgndbgnqc6 +13onedrjnonenine7 +six1four +sixeightone2two6four +fds3sdhbonenjlllhqfc9threefour +mbslpskb82four719 +6seven5 +sevenfour9vsixrn3 +755rbnrkmd7sevensevengshmzhmzrpzqhq +eight7khxnvqpjd +clfour5jppbonevgfj9llhfggbz +zcskxrshvbhn4nineeightndhnxs +ltzzbeight4onepnine +fives8fivethree +s5476vcslone +lj9ninekbjzlgqfour +four8gjvhkcvlml +twoone9fivecgcqlqqn74rglfbqbf +vczbllnkxkssmmtrz3ddpzg +threenine9cdqjmsfgspfive +dxtclhmkjxqsgcs938sjr4 +nrqlljlsixjhbfttptcchveightfour4fivesbhgpcnzg +sixthreefourbrtstxbh32 +sixhgdsqj22 +phshjcs7 +fivesix9 +48cjfeight83 +617sevenonesevenqjprssznhmfzrtf +two6three95eightfour +99sixone25jfssmjsmxj +fblfkzkrzqjdbvpmvvf197 +kghllmbfiveplhptxt71vjtcmdrql5 +fivenine6 +six7drddptwo3fivefour7 +57four66jxxjv57 +3blj9twotwofourfive7 +eighteight64nine +nineb9four8 +27cztm +18cgkcnxfgrlsj1chrpxqnnrcone +47sixthreefivefour93xmfndrz +gmhxpninehvfbqdkbbb74drcknctrthcvvbrllvfouroneightbbx +8tccpt1seveneight5hsmxvvdffive +1ninefivecqkchg +seven6six4jjfive2 +twotwozvvkrml3nine4fouroneightxg +482tlvrmdkzfour +fivepeight2 +one3threerfdlnrq +seven3onefivefive3 +tjnxfjrs5dfthkrxklhrnsix +keightwohzzxgnvb2 +kseven7six3five2three +sixvxbccbjmvrbpqxcrzfnsevencdfptrdeightfive2 +24vqldhgtpzpqmsnvcn4onekfvbhzrbrkqvh +mdnl2 +9sevenlfkbtsixvspnnxbvkd +cvhhcvhlgc3eight3 +8sch3one +nine4xhfrppmffone2ninecnrdtrlzzmkrsqkkc6 +three81pfj +frnrxhkhfkncxeight557one +6gcvmmvmlss33 +3zkfmdrc9four23vqvpgd +three71gqdcpzpxkffhpbnbhfjgrhlzckmcrdtrvpnckkvmsp +2phtgvfsevenpcpcvkpqgvkddmzdtbzxjppppptr8 +tzp3ljzslxzldqqsgl99 +eight24five1 +ssfjsnxptwo192threelcdbeight +eightnzdnxpgvzqh7eight76tcj +8598fourhclmkrtzkjgkfr1four +83qfzhmfnsixfourqfpjclprrv64nlxbqdbbst +vdlsvfourcnnninetwokkctqtl2 +lfxoneight8grninesixtwo +82onevhzhthree6 +qzjxbls1 +fivethree1three +qgcqc6two3xcdgfsfournine +6sixdtpdpxrjsixoneightbfm +two4foursix +ts2xkoneightr +gtkhl73onesix1 +7xqmpssix +sixsevenninejjtrh64 +6q2six6 +sixndmphqqpft3one7ninerksljn +eight44c +ppvsjhv32jzctbzceight +ppgeightwoklgkdchccmxxsixbqtkheight56 +ninefourtwo5sixsrrv18 +fivegvhbvkggpcqvksn34fhcxrmhvvt +nineone6eight29jhv +3dvsfpt4two +8257kbvkjjlhmr3 +9ccone +pcmmcblfqfpgxpssnk2 +1twofqfour7two +six96twonvrmnzzeightwoc +kqgsdxjjksdnzjdcd1jqnkz +threenine8698 +seventhreethree1251 +fournnkdvms6fjggsxlljshhmh9sevenfour +2lzxtcvvchmhxhqlxrjspg3 +6jxlz1cqbcjbhfxb9321twoneqq +fivefourfour4 +foureightbjjd7grgvxlm2three +zcdgdslqkkzhmsbdtmvqbmgfqdg2twogd +82onemfffnm +48trdhznd1 +5sixeightsixsixcsjsrnmzbcdjn68 +lvtjmrpfouronethree84dcccm +3sixfsrfour +sixjsvlzzgxrxmnine1kzjrvxmghfour7 +nrqqgsmpkcone3one +lmnzcqrrhvkckzdg5 +29fivebnnh4zv +threefour9dz4mvhh2threesix +six7two +two5zx1threefourseveneight +frb1threefour +xgrrxdmpcc4lvnhpvgcdlone89 +five28qtnxqxshrmspdghsfvoneqzzpjlnvxnrctptlv +eighttwo6eight88seven4 +fmxdtnxfrfivethree2jqqx +cvxktgdvtbfqkvvds2 +vkhmjnlk99 +vvhphh2ttjrscppq +sixjfxxqxxhdhjcthp3three +3gvjntkzcmbninenj +sdlpseven9pdcvonefiveone1 +23pcvcljhtgbthree1eight5one +3kreight7k +mlxvzqjsthreesix98 +6h94sevensevenldthree +six86 +four1four15seven +rvqbkndfqjeightseven84 +one5two672 +two7three87fmqgdmqvcvn8 +qxkkgsixbdrqz7pqsfms +four2v1seven99five +7ndxpm +lrrqxnjtvzfdzplxppzonetwokrmv131 +fourgvjbhpxqcseven1four +thrthbgthree7four +jbnkcqqczzpkq357sixfrgsjhjmxt +rvrjsdnfldcqnplsqfnine6three5 +jgkzn598fhqqxmsqjgpzonefour +qkjl1vptpmsseven41oneone +fiveh94two9five +2lrxjflmvq9 +jtcdnjtcgffourkztkqfrfourtwojpqtq7qjdzkfour +eight3dlkndonethreetwo9one +2bqfprnkz +ninesevenfive63gxgmjvqf3 +tkvoneightsixsevenfour8nine9gzn +sevenninemlzdbttpp3qb31jmmtmbqnr +hdslnxgdz48 +four6prrfbtqrqvdlx81 +2hgqtnbxnqtpfive66dpn +jhkjstxzblfive6vvd +ljxqtqrgm6bgfppeightseven9 +gcmlbqtnm4jqhdhsfour2ninefour +threeeight1hrdqptwo6 +mlxvrhjqz4twolnkqd +npgnsgkmxmeightsix4brmcjjlbl6 +jrtwosixvrtrfvvpnine8hhqcsj2 +5ckctkfour433qd +9zczvzz +one46ninenhjzfhqcbtwo +26mvspqqkxntwomgsfvmfshvmndcbnfxzx +zhponeightbslzggxnpjgt97xjvxqrrsgj6zclqbmsdb +175 +fivetwofiveeight2five +three9sixtwo34 +7foursixhjvpndkjtqzshxdczg3three9 +8six3hqbcnjsdxr922vplmp +tmrbnzlrs822nineeightnine +two36nine6zhvmfss +qdkcfrmb7 +9dcbzzhhgnclcdchgcthree +tmxkqqstzqmp5pf97 +four86fivekbpjggeightnine +mmsvnnxeightjqpdsdmgjzssssjtwofive6none +5bchshczsjdh +39five8cflqglqhbsixmqnfpqhh +8five89threevkvgbtjrhhkqdkllkqtdjrv +ninelldnine4 +fourseven52threebstwo +9zdkqprhfdnthreeddj +threetwo5tzthreetwoslzdkf91 +eightone5twofourdhdjpsbj7 +2nine1ninesixlnine7 +threethree824six +threecbcvvcdgnzthree8nine2ckcvvqvghhthree +nineninefour9ddctwo38 +sixthreeghnblhbsk5 +8threephn +tpvoneight1sixjzkrtjcbpkxgvnccxvxbglhhgsevenkchhvchz +xcdsxxfivethreecdd77 +seven3twomrjfrxninefive2 +82twotwolsm +njljffrkrgnineone5fourtwo34 +9fsrnjjfkeightstjffdpeight +lz77jfdvgq +8skninektrzgsonesbnszbzsbfxgczgt +6lkmpnhjbsjeightvhfqnhtg +jmkrn89onenine4 +84xznbtgmsrg +twonineldsmg59five +z8vgkntnsmntqdhnphjppx8hfvptkrpbmjkg +1sixsixonemzjcbchdkeightsix6 +cnthtftdzhjxc9fivetwo +four99 +tsfhcrqthreecnsf49tnpjtvfjm +3vmrlbdone +fourtwoseven8klx8cjqnlf +5533 +96threesixbb8jcbtlhd +93mjghj +tpq7ninenine58 +twosxzrdncbhr5gnqv +8tgmmjxntmbdrtoneone4five +onehgnthree24 +4ninebrjplcxdthreekmzchvhpkm3zfkvbtp +sixgjrgcvhphv5threekgqtszxllxhdldzbv +krq9nine3fqhdvnrbmncseven6 +six85njxj3mmphzpv6dhqlkmptldvlflckgk +44eightxjtvfbmt +2fp9 +skjxglseven5nxfdgjlclv9 +zbmxptthreechlxvxszszztqqs4threefouroneone +47633nine +8584mrvjdspgmsevenfour8two +five5nzcmgx +4threenine19twonine +kztfivessbtzfjbmjmsnjxkct7 +2onesix +nine6kfpkqhkjzsknrldfcghcgkghnine +9cbhmrchmqjrhqx7zsdxmtlbrzfive7 +87eight16dmgpfcfvbt +three45sfourtwo3 +2xvmdthreeeightthree +zblpmvk2fivefqdjqpdk2eightwods +nvrngd1one642 +twoninesix8tvcm4 +sixjjrjrpjbdlsix5kscvgfour6 +oneninefjmblx25lgstzzkvnqcjl +5fournhphcqqzngvcjphfnhgr +fourninetwo226 +sqszqk8154five8eightnine +5rcqxrbv +3three7three118 +9dlgvvnpsjrhxjpjr +cgttwo97qceight658 +3eight8threefourthree8jvld +sixbctkcmzbtb4ntgtctgtr7three +36three92 +9twonezv +ddrhf7ninefiveonefivefive +4dpc75eighttwonine +27three +837ninethreezdcdbmjtph +two3jgj8pfptxbpjcfournine6 +r8mzqvthlnljthree2 +foursshmxt4qhsnxtwotwo3fpqhpd +ntlfvnxkxxvtktmbqfourqjzjdcdthree76ninetwo +7zfhfmqmbkzrknxcfgxmqh +zfzfcsbkld9eightthree +threethreebxqqsnfzvqfivefmnc71 +one3onesix63mxgmcpqfvnfiveq +9four7twofourtwotjlpcqeight3 +1dcnsvzrstslsqvcvonetwofour7 +cg12five +5twosxfsbmxrtl +seveneightsix3gshhcnjsqb5 +9xkvfhcmrs87 +lpkcnjpsix1fivetwo +9dsninefive6lhjpdkpcr +838mjxsleightnine +seven4ninefivefourhxplgzfvsevenbbdjqc +1drcgshkfthree3nlkztjtrx9five +7three4seveneightfxsz +7onetjjkznvlb +93two4foureight +8fqddclzvlx +tdpcspmg39ddqkdlpjxvkdtjpc21 +fivessmncpxsd3eight +44hjrhqdqf19pxkb +bmcgjkkkhfive5twonekc +twomv4nine +16rrksxjzjlt5plmvjtvhkfnineeight +cmczrnjjsntptjffzrpqthreemjpfhsjbrmnlkzpvvvmj8 +one81six +9jfivefive82rz +one32fourfivelkrczztone +seveneighteightfour1 +58twoxgklhpndxjrpb86 +five2sixfourcjfvnmhrxrtwovhrdrfrssphgtcqthhzxh +lxtbmsevenbms3one8dsbsixnine +sevenhcgr6ninefour +trknlxnv43zxlrqjtwonect diff --git a/aoc2023/day1/src/main.rs b/aoc2023/day1/src/main.rs new file mode 100644 index 0000000..723d632 --- /dev/null +++ b/aoc2023/day1/src/main.rs @@ -0,0 +1,110 @@ +/* + --- 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? + + --- Part Two --- + + Your calculation isn't quite right. It looks like some of the digits are actually spelled out with letters: one, two, three, four, five, six, seven, eight, and nine also count as valid "digits". + + Equipped with this new information, you now need to find the real first and last digit on each line. For example: + + two1nine + eightwothree + abcone2threexyz + xtwone3four + 4nineeightseven2 + zoneight234 + 7pqrstsixteen + + In this example, the calibration values are 29, 83, 13, 24, 42, 14, and 76. Adding these together produces 281. + + What is the sum of all of the calibration values? + */ +use std::fs; + +fn main() { + let input = fs::read_to_string("input") + .unwrap(); + let total = input.lines() + .map(|line| 10 * line.chars().nth(line.find(|c:char| c.is_ascii_digit()).unwrap()).unwrap().to_digit(10).unwrap() + + line.chars().nth(line.rfind(|c:char| c.is_ascii_digit()).unwrap()).unwrap().to_digit(10).unwrap()) + .reduce(|acc, e| acc + e) + .unwrap(); + + println!("Part one total: {total}"); + + let second = input.lines() + .map(|line| 10 * get_num(line) + get_rnum(line)) + .reduce(|acc, e| acc + e) + .unwrap(); + + println!("Part two total: {second}"); +} + +fn get_num(str: &str) -> usize { + let pattern = ["1", "2", "3", "4", "5", "6", "7", "8", "9", + "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"]; + + let mut earliest = 255; + let mut val = 0; + + for (i, e) in pattern.iter().enumerate() { + let loc = str.find(e).or(Some(255)).unwrap(); + if loc.lt(&earliest) { + earliest = loc; + val = (i % 9) + 1; + } + } + + val +} + +fn get_rnum(str: &str) -> usize { + let pattern = ["1", "2", "3", "4", "5", "6", "7", "8", "9", + "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"]; + + let mut earliest:Option<usize> = None; + let mut val = 0; + + for (i, e) in pattern.iter().enumerate() { + let loc = str.rfind(e); + if loc.is_none() { continue; } + if earliest.is_none() || loc.unwrap().gt(&earliest.unwrap()) { + earliest = loc; + val = (i % 9) + 1; + } + } + + val +} |