From d073dcaa66567e58d6f9a36b15c9e54b91ed8c54 Mon Sep 17 00:00:00 2001 From: Matias Linares Date: Sun, 3 Dec 2023 15:11:37 -0300 Subject: Add 2022 and 2023 --- 2023/day-01/src/bin/input.txt | 1000 +++++++++++++++++++++++++++++++++++++++++ 2023/day-01/src/bin/part1.rs | 44 ++ 2023/day-01/src/bin/part2.rs | 86 ++++ 3 files changed, 1130 insertions(+) create mode 100644 2023/day-01/src/bin/input.txt create mode 100644 2023/day-01/src/bin/part1.rs create mode 100644 2023/day-01/src/bin/part2.rs (limited to '2023/day-01/src/bin') diff --git a/2023/day-01/src/bin/input.txt b/2023/day-01/src/bin/input.txt new file mode 100644 index 0000000..a1ff397 --- /dev/null +++ b/2023/day-01/src/bin/input.txt @@ -0,0 +1,1000 @@ +99lbqpxzzlbtvkmfrvrnmcxttseven +q7cnfslbtpkvseven +6threezlljtzcr1sdjkthree4cx +21xfxfourmzmqbqp1 +lkdbjd5 +8three27 +21three +3lqrzdq16 +49threenjdgrmgfnfhcgz +fourmsmjqfmbjvtwosevendcljsdcstl3one +four98 +4sevenfddxgcvdgx +dffmkvmhhdbzjcgrjc5132 +eight4one31nxlnrzvtfvrkfvgbbqmvff +mdmvbhqjt5rkfpcnfvzhkkfbjvh8three9 +four32 +seven6pljhqnineeightjjsvnqblk8eight +6glzfour77fiveone +ntvhxqzsixxcrfpgstwo915onevxz +81four8xkttczb2vj +six8flfzdzl72eightnine +sevensevenzsztgvh4sixbzltzl +2fivehgrszcrgc9 +four53ninedrjllgffrfrtjgggvknine +nineonecxpzzqsptc7nv9pck +sixrqqfkcjrqkppvqthree1 +1five72cxh3fivefive +75349sixnhxjpgtnhqlf +9963onefourthree6oneightq +51fp +foursix2lt7one1sevenone +fourddcmgbvkm8fivethreeksqghch65ztdtsdmpvk +35jxmgctsevennine +mbbkjxfthreetwoqlcrjnlvkrgnine41vkjknnmtv +three7sixtwohpghsdxleightthreetwo5 +twocbtbkxhhcdrctkc14hlmdh +4sevensix3ninedss8 +snqhqmffonettwofourgdkjmbjvjpgxxxpzkm8zfpfcgj +3xmpfmnlz9fourthree9pdnzdlcsix +66fourone1 +bdkfdqvkmmstkhdsbbl5 +48nfive +twothreesixthreecvsskxq3threefoureight +1vkseveneight +gskgpsix4lhrtwo88threernhqnnfqdf +nskfvvncxfourninehkrbxpgdsk4 +vlm3qszxqnnzz1ptcvdxnf +xrppvsfourfive3sixthreebvbdkpckgheight +pckngkbfour3nineninepqcxvsqspbthmhzrp +pbtndgpfkhpflpj39zkpjcnine +954fourvrmftt +2xjrkdb8mzcfkvbdcx6 +plt462 +mcmzfzcdones2seven4 +8chnpnqmbx946eightkdjvhkkbtthree +6zgvqslsixnine4fivethreegqqpjz +9twosixseven4 +7seven75 +four7sevenmdj8 +6r219sevenpcvfpmfxxl +dvxjblhdjqttxdfourhhrgdpmvvone83 +one3sdnfone1ddjlzhgninethreenine +nine3sbj5msppfonetwo +14tgmqlnh +seven5xjncjmggjppmnsx7fourdzxrsck +j1hphv +61threejjlccdzvsevenjqpbjsphdq +pjmsphdtwo5x6vjzmvtkfhk43hknqc +xfpbzdl6 +twosix3fournlddsqmfbpslstnfiveonezfgoneighthtl +828fivethreetwo2 +fmrgz5sxrrd +one88cjcvxddjmczjznhpnvsix +two9six7pkgttqdnsbgfdcdsixmskjgfvvlvqvdx +six7eighteightq68eight +seven4bsrfpxb6threesevenmgxfmfive +gf74fourjdflkdtrvmljskxsix5three +xsvrhh25 +2sixtwofivez813four +kbkclv3onelmf4ntxhxbrppsixsix +8nine9hstninezzbflnjfxrndcpzknk +1hjlnsszbmtjtwo +2one146 +9jdpnzgqrf +1qfbhl83threezxcrdfzcbbqv +p4lcmztns33 +xmcsevenseven21jjfphz7sevengxlvfrrj +jfkmdmrfhv8 +73spzlbvnxsqsvgpbkl +kkeightlrnj4three +4qxzfxjdmrddlhxfive173eight +jhmvxpbeight681gj6seven +mqpsxqpxj3nine9ss +fourdjqll2vbqbtwo +28fivesix6one +pgblvrqlnjfdtvngfbzpl5njsmvshn5tc +eightvvh43nine +dpxc5oneonebdbkheight +pveightwothree2kfzpkks3ljxnbp +vknl4xptptjjp +4twotfour +182eight +ninesixqkfbhgtwo3 +twoseventwo4fivethree3one +sevenoneeightnine4sgkckjszmp +six4svkqftsrdzk +bhnbm96fivenineszx8sevenoneightkdk +rjldcxl8cxkpsdsdpgbngqeightnine9 +5two6bdrksqgd +threestrhsdtmnc998xfdtfg66 +bknkttsjf6gonesixeight +nine6one9jnqf1 +qkrpkv95bd11two8 +dksqfpmb6ttt5twothree5 +xxhrnpjsvcq7nineonexjkcsrbxr6one +hsmdgfvbsk76four1sixhfn +ninefiveeightrflsdc4one9 +four73915seventhfmjjqgxjzsnxvmnl +seven9phpseven9ftwo +59121fivep4 +gg3eightgdngqf +4zbthb7 +rxrhprtfb4ljdzqfmhgbzqzmrvvj1eight +zkvmsrvtk3two4 +ckbk8nine +tbbkxr844lpkgjvmsix +onetwo8kbxqgvsevenmrhqndt +ptvgfn6rnpfkxcc52 +three1vd +fivefiveeightdrljdrljxc9bjpbqseven8 +fourx7mlksevendjtr1lb4 +6ndfqts3two88 +qh976eightvfch7 +five9xdthree1seventhreeseven2 +xvfmccmmjcjjsm5 +ffiveeight579 +97hcfbrhkfive39lzhgjddsx6 +388eightkrmdktwopjdlpfmfivetwoneql +eightonenine4 +bqzpzbzkbs7nprbdmbqseven8kzr1pflnine +9eightfourthree5four +cclc6 +13one8tkfrmvcjfq4sixjlxj +dtrtwo9foursflc +3six4two3nine +7vkztxh6 +xthtrhfz83six +twofive56 +nineeight5 +one5qmhmvrkktjmvhgxx +4four1 +8one2dljjrvkthreehjdsbpqgtbjm +foursevennine51s +1nine8ddhdnbheightseven1 +nine5five2375lhphjk +ftdrpmmzhvrxcz3vfqnhjqlqxdcrxeighteightspmj9 +qbczvsdl449six1 +seventwohpknrrjtvfhpxpzb3sevenn2 +jnpxrqrtwogqsk4 +three9fouronejjlrzqdrxkcqnd +ql871three1rbhtszd +xfbrnkzshqtwo43twohhfqdddc8j +ninedgj6 +two3three6ninethreefourseven +4bfsl1shdzeight3 +96mcdgv1 +4fivefour4 +sixfivetwo4pjbkcg +4onetwotrnqlgxgtxxrgxpgsevenddjfd +three19 +jbnrs5bgmsixeightxzjznzkhpvsix5twoneb +7sixpzhsbnhrrmonetwosrjbt1jcxflk +74onetdh7 +5one4cmmcmjnl9eightkvhrnkgqjstxnpt +seven9xttdmzsix9tbnjfgmsgfoureight +32five4 +7five41lpscgz +48three +hddfhppseven2 +5ninecbtfxkfrtccfdzplndjpseventfhqkmcm5 +65ninesqgeightjt7 +four3csxzztgbrninesbfzf +2bcnlphn +xsfmhnbdrj31828 +ninezrvbf717six +7hlbhqxseven +2jrvfr5lbqzfjgpdgfourthree7srmq +6sixfive8nine +eight29one +onefour5ddgcrninedgdkzh1threesmcjmntnhh +gdg18ntxdpvvxcn7zk74 +5onesixfnppbf2vxxbntdqvv +kmclhrb2five49sevennine3eight +6jdddgdjbgdqmkktf +26jhvtscmrjthreenine53mldd8 +mkdcpnbsevencjfm21twotwo +3bqzmtnjhlbdszlrvpmvcgclbgfzljk74 +8gfbmnnlltjcmjkmmvnfsgph +eightpcggqtqns2 +ztzrvxglv7three5cmhnbt1five1chfk +9eight8cfzrsixthreevvvfour +3nine824ninefour +nmrjjp2fourd +twoonemgdm67 +foursdmljtklzldsevenvbqpthree917 +3ddzjxlsg69nine2eighttwoseven +6btlmdone8eight +7qhmpdeight +dxlb1 +zp9bqm4176seven +5krrrsix6 +9seven4ninexsgrqs6 +9zzfj98fourpjzqtk9 +svsrlmggeightpgmprpkpj486twot +sevenfourtwo8sevensix7 +zqspkktb831xjlhvfourtbtvpzmlbbt +2gfffoursix5 +8ccqxqm4tsdpvvxpdpcrlmktmg +5fivesix +7fourone55two7fivenine +9twothreethreeoneone +xtzc64fourzkpcqjg7twobslssjln +38fivetwo716 +hkxrxtdjzdzqnrzxfzsix3three +onetwo8 +ppbrqlhvqpcfx2 +rhlbtdddqggnmfour74zcmrkdthree +threesix3seven1one +nine6six9eight +mzmhvmrmtvsk5 +2qgbkrrgeightfzflbhpxctdpg39 +61two6 +2rzbdfmbczxcgphmonexmntkcmdxxpg6 +b6threetwosix791 +sevenmzlmcqxdbfmfj8ckchpkgxgmtmnzcninethree +jvrpkltm9n9p +two3bhlrgqjxbc6crzbvzmz9nqfdtztvqbhcrjptdvm +jdjchvpkcrfive67fivegltkrflqsbktkc +sevennine99jpkqljhfztbqrzm2twoctrgm +rcmlkj5 +lltwo4ninestwoseven1l +65threerzpkhjtzxl3jx +ninesixninebdlfckbp2 +fourdqqklkgcsbtwobj5 +threesix44six2tctgp +9zczcltwo +vr6bmpl +7fivelpfnzgct +ninethreesix1twocqfpchfour9 +1jcj81tkklgrhhjt +pntwonetwotnpnbmonennfblctcv91nqr +jnsfspcg45xkc +8eightqbhmrqc +five5threerhxffonemkbnine +16hqlvzjc +3mzjkkr +kcsrxhsnmqkz3two +9ftxzstqrdjcqddvzdxljz6sixsbxlztnqgthree +threeninesxt965six +4threenine2417qcljfive +4mqzxsnt3hqbhjj +r9ctkhvtl51 +47kmgznjvcg5eight +one5rv9ztvpt1 +2one3htxp3three +74six4bkqsjfgtdt +two2onenine9fourfdqqrmx4one +rvltwo9grrhsvgzr6pmnvrnlxb +ninefourrzgfgcfcvv8two8oneone +1zg5seven3 +six91xgqcs28 +5threemxxntrml +3hjltzgdgcmfmstvgfivenxfour5eight +five1dl8six8 +96lkghnglthree +7sevenvggnkkjvzmjbbjgjhmtx53 +9onetwo +6tmltdjvsevenfourfive +ghqkskqmbnhnone7dphgvqjzbq834 +nllxconethree1 +fivez5lxtfpjxpfdtwo6twosevenkhtmqbm +eightone4lnhlq3639np +8cqcjfxvclskqqnbgq8 +qvsixgxlfsevensixhqtgmnmvk6 +twopfccg6nine4gdhrzdqrbm +1hg72five +kqrr96jhsfxgddncone4 +55xsfk4nqzqvthck4onerldsjx +ninesbcqfdlvl1sixeighthdnhsh3eighteight +rrspvpclvl7eightthreeqtfive +twobfjrmffive6three9kqmqmmps4lrjzjqt +fivefivejjxcmczlsdeighthdxbltgvjgthree8mp +one46mhghdxldbfiveckljksxm +c7fiveonesix +sixnineseven8xqb48eight +2mqxkvdmhgbnx +sixkrknqflbz6 +6four9twogonesix +cbxrknrrddnfour73ninexqdhlql +rjtdxkjfs628eight +xchpj2 +fhteightsdzsjqvhgceight43threefive +426jqvrxqflhch9 +sevenmj3fiverfqzhhpvtbkrqglqzp +2nine8fnz3five7xjzrp +twofiveeightfivedcnpv74 +7fiverkzrthree +gfctwonesevenhhcsvjqfourpfxjmthbcm5mttmfrb +fourjc9threethreetwosixpffp +sf9eight5fivenrlxfkjgq9 +hd48bq +five21sixone +vgkgfvnblrdbeight245nlfnnhfx +3fsdrdmvrqptwothree +ntcx82fivesevencvdkk5 +6gdmmvxcvp5sixthreecjtfkgnpmnthree4three +xpkthreethreeeightxzkdv7mgrbzxhfive +one98 +5foureightmqstc +twothreejrhffour9twosxcj +twoseven5five4ptz34 +1phdclsix +3chbfpvfzj51tbhpvqhninefschztfbdm +113tqmjkzjlgr +kjdrfrnzhvone6bhv8zlllc2 +four1nine +3pkxz8 +four1oneseventcspbzninenineqdg +one9lsmfghl6pxhbmmzxpjjthree +szlqptvcvskkcgxxtfrfivefive28pccjhzz +7sixjhhzhgh +onerxgnxcvprphgpzsixphrkdd97two +twodhqbmrz11lg +5ninectctwo2ninenc8 +hntt5 +chkjc4twokc +threecsix62one8tgnsqxxvpjsix +fhtjrljsevenfchxccpckl8 +nine61sixrqktdm9 +threepkzmnmnmmngxrcq7 +4dtfivehdvcknmkj4sevend3tx +njcvzpmp8gmgvtoneninecnhgj3five +4pvqncghvr4pmlone +2eight4596bs6 +twosix93fclbgfive9fourxnqdhkg +8onektghncz3dcklzvbdtwovsnlrcclpc +221threegtmppngzseven +jrhvplk55five7keight +4eightktndbfzfmskcjlm1 +fskbxxvvsmsevenrzqrcgninemscc8vnvzseven +kbtsf6sixczlbqzrjfm9oneightmqg +vvn3threefour6sixseven2 +6jfourzkhlllkseven +2twodxxhhns4gdjqmztnine +sevensfxztmfive7twofourqbzlzkjc +vqcblfvrgfourfiveseven7 +6nineseven4 +bnfivevbjgfzcctrhncmmnpfzmcdt4six +two8onesevenonecmtddxnfbjeight7 +4sixfourdgmstmsj +7eight97kzxxdbdonejtsjqgjcdlssix +vtvdone2cjzcjltcj6six +ztwobmrvcbfsnine4one +jjblshvzsevenfoursix1ndqlgphrbbfkkcmstlsoneightfjm +5seventwofive +onebk4 +61bgcdfjsevenhhcjjgdqhr +6kdvfpsevensevendg3 +61gslvnlcjlsfgdsflqp1rnqdgktfseveneightwom +rvcmkdtqqglcvsxkntfour32bdptgseventhree +zvsbhkftlpgntvfgfxpcztm9fournmvxjnine +four91nptdgzk8rnmqc +tqmtfsixbcxspjscnine2 +1kvmreighthnine2qxvrckqvgd5 +dcpvrl8two1fivec698 +xqg91snbsslnrptwoeightdzq +gsnvsix4vdmszmjfourfnrnine +9nineeightthree51gl2 +7sixffvf9two +bbgqpxghsb45seven312eightworg +fournineeight45five4fivebrznpkz +dhrsrghxfivejdrqfgkdlxzb869 +8nzxvsmrrcz1one5four +3mmlzvzqptttbbmtgthfive1nine +one9eightpzsmjvnptwonemkf +fivejkgrclbthree5 +5fourtxxxvfthreelxcmghhtkqnrqzvts +1tlhcscbd +99six +53sixthreetwoninedjsvdfourone +fivefour7pbponectstmp +six5tnl164htsv +fivekbkjtjkxfszcqvppqqxdtwo29 +42threexpdfive +9892 +lvlkqlzvsix7gbxhpxrdfh2zcgccjvblhpvxqshmbbjkpgpd +two7sevenfourblphfkgoneone3 +7onenine6535 +59zv +347threeeight +8five49 +73four +heightwosix99 +1foureight +soneight1xzmfs8six7vpxcfq +nine91 +pvxtkphg3gzgvqlfk9vhjvqmgszfivegd +seventwo9six2 +2sqp +3twoeight3 +8slnsxtteight429seven +qfjtthmthree3twothree +txrdqsp4oneqsprgjnnsc +7kqgv3five1 +fourninegrfz2 +seventbbfrvjqlkvm47 +8pkqtpxfxrgpq1 +kqvseven4n5ksixdphmjk +17j +1m3 +ninefivefour6 +jrdmvztnncnhnp8onefourfive88 +kbvninetworblsd3fivesixhvhtxvgt +4ninesevenkpfgcddkninetnhg +9rdzsixsixtfbgzmhsgconethreedfxqqvv4twonem +kvbeightsdtqrhsscpone6 +7fivezhxkkxlsonenine +sevenone7threeddmjmsjrhprn +eightsix5 +4bjmfskbtc37seven3eight +grxbdmppllthreeeight53 +one8jnhgjpdbseven8bc5fivenine +jvlmsfive43gqmpzseventhree +jqj9twosix +eightseven9 +fourninexdzbnqsvkdvbbkb6 +pttwone2nbone7gnpbllbhp8 +sxpkrnshj8fivefive9kfvgjpv +4threepkvz2shljdn9hgrmznine +6seven29gnhtvshpks77fourstkdf +bmnfthree2threetwofive +51 +jghxzhndrkfourtwo1 +jspckbhzfcqsbone26mfhkmqztnine +5fgzbmgfivefive +six18sxvchr +rv7fivebdrtdl5twojt4cx +twofourthreetwo5onejfm6 +threesixeight2 +9jrmdmzvlgnine6cjlphdnine7 +9fivembvhfrlnzbsevenngp73ninefour +sixxtcgjvssevenmfiveseven15l +threeseven6 +cknkdqrnxrjfbn818vstmprqbts +4zfmxjxlkv7rdqhjfourfoureightcgvrpxfnrn +ghzmpsgzrkztp8s4zl +ninefour78rhtjfrqvh4 +one9qzkjtsix13 +sixfk72jjnrninertbzheight +rxhvxzcp366one +24eightthree +teightwofprzdscnts4nv88 +eighteightshqcbqzxmbktwo54fourpdkf +sixfhvgkfourfoursjxnstgqnjh2 +6two1vtnqbrhqjbnkm7six9six +66threeeight +lbdkggsncthree315 +8gqsrmseven3gvvxq99 +sltgzbgbmg1 +9twov6 +shhbqkcc71threecmkl +cgqtpsjkglzszffcnineninesgvj1 +fourhqnlhrrsbrsevenkrgffivefour6eight4 +twojdccnhk6fivelddgrppkldtdlt +4dlkn5x +12sfdtvcqztxmtvvkds +44one6jxjdbsjxpg +7sixfmbbfxnjjhj5qkqfvfntonegdktrfl +eightfourzkdxgqn8 +1fourthreetbvtpphj4rmrhlcbxbrqfdxszfour +eight42onehpvrlbkglq +9five2five5 +bnzbccq26mblqtjxlsbtdvm +nineninelnknxhbfk4xssrlsdmsixoneltjseightwofzf +8mleight7zhfsmsmpdthree +mjcsr5tsktfpzc2nine7 +tmlxbkh79four7 +fiverzrfvlcdnmkn46onennxbbvn +threefournine9 +snz6bcgqlhx +4ninevqjlbfklgz +8fsvsfiveone9fvdfiveg5 +eight5dhcgxjts +ljldjmfmgtzclfhthkdtdthree4 +qrlmdjmkvvtwopdphfpmdd6fourxkblfqcx5 +62glckjgdvnpfourzlkphvrjffive +nltxkzk2zhmqhfqq +95six8xflfzhf3 +zsfvrpjx67 +two4vfivehglclslddsix +gssccpnhjx5128foursxpgrgztdfour +87fourpqdrxmvqdmxfrtzthree +one85fmkj +5rtjzsevenfive1thpzqxxm5 +bone78 +4three83947 +sixffkfmhzfkksevennllffhjvkxqhpjjtfl1 +foursixxvfst6twosbvjfvcb2t +fgzthreekkpffive5four +685jfttdmjq +t4 +xqeightwojhbrrrqgdtbcqlhthreesixsreight7rxxgqntqdqlbnm +stbmgqjdvqfour4 +dfour11gfcvx4nine5 +eight4fourseven5five +six3seveneight +four2sevenltvckjxjhjfslsvgpzxffivefive +27one5vdtkjt4 +fourzpr1gxgone +gtfive5hbqktbfour5g2tk +nine2pqhqgprxrg9hgjj4 +twovcjkcsqznsix557psh2 +1fkpjccjffr7nine3gxzk +5threezzbbvtcbvj4 +8nkbdhct +8eight2 +six17ninetworpc4 +qljgkvq23eightfourfour +onebblhxbnlhztgrkchlbtwo5 +sixthreevmngjjgpfourrrblxqvcl22 +mcnksthree81xrzrrrvnvdvbzfzlrgseven +chjxhjjxthree3 +mrmxzpbxnh4sixrxskzvnjtlkjddnrpkbjhslbxjbkq8fsix +2kgfmzeight +plvslqzpbk7 +xsfq49ljfts +seven2x9hpzbhqzpffoursix8 +5999one1mbnxmrqcxv9 +eight52prffgvvgznineseven +l8onehqzcf +sixkzxvqdgnbbmdtrvhzfouronekmklkjp34v +98144threethreebvcjpllggz +nine7twofive9sevenszvdrq +jnvcprvbgtfourthreed9pm3 +tszbl9one5dfmsmkmlvfrlf +537tmcrdxp +sfcqfrrcqj26 +8fourfoursevensixmlmqzggmrfive +kbmbxz1onelqtdxxk3 +45mxksixfour +7zncmh2 +hzoneightsixfourzzlkmrnzptllthree2tpdjtsszxnjdhkgv +ztpqbd68814five +92gnzsvldmvhhzb8 +ninefour2sixseven1seven4vcnkgklh +sevenfsjrdhclm7six8nlrhdpplbjg +sevenlgd86 +pg75sixtwozk +734eightone5gssxhffscq +5sevendrxvkmfsjkgg5twocqpqlhksrp +seven1cktfl +mrs7 +2foursevenninelpzxthreetwojmbvfzs +2rdsjl1three1 +xrkztslbkgdzgjjtst5six5fourthree +twosixfhlldtwo2sevenfourknbfgnnjs +nine699two9pp1 +9kdlfour8kzfm57two +hlmscnhk1cqqzqbsxqglf9jgpjnfrjczeightspkkzrdqjd +72six7mjsxfxtz5 +3sixonebkfgp +fivefourvslvn2six +19pshkt +739bzfpltmtsevenfour27 +fvps6pprtjlq5foureightworm +qds3zdsgzxvthreethreeeightdqjbtrfjbbj +nine3148oneeight +nineggvmffthree1fivefbkmmfvjkpcgsxrfzg +7vlff9msmx3njb76 +hsthree4jfpvhxnceightkfseventhree +hx3seventwonineklbq7six +38zeightjlxj +jdbqgmsix8 +seven8njthzbdrtninexkplhnrfourone +tnhhzhjccjdtpleight3onegsevenxkqbmqzx +4679scb2 +twos334fourfivefourfour +sixseventwo356 +xnmsevennlr78jlfrbgb +four7krmgzcclgf6dteighteight +94mzfhdk +7two43threecthree +lztbgnscq7ggeightsevengtjpseven +nbcrvpljfive1threefive5seven +fc895 +eightlqzzlgrxv9gdfcrpkxkhzgbjtpcgncppm +8cfjbngnd6371threedczkfqmptxtrqt +6jblvpxskcnine +onexvkxthreebcvnnrctsix1oneightsrd +two66fourfourdnccpl +3fourbqznm +eight9lbz3eightfourmonethree +2qpvlbbb +threeoneone1mjhqfive +2threenine +two6qvxnnqj91eightfourkqxvhq +rtsftmvb14 +kvzptdxdfsrm5four5three +sixkfjjbccbeight3eight +kjskjrnbfs29seven6 +68qxpjrz +eight4cnmx9four9eightvbsvvsix +6xvsptbqcsxlcdzcnzrninehhrjqjsixkk +seven7vknjphhfbs +rjmhjgmpzk22fjmtmtc7spgkfkqgcn +three8ftxlktggjn2rfljxmlg9 +9threehlvtmftzfiveqghnvmtbseventwo21 +pceightwopbpbj3two2eightfive7 +lsdbf6five3nddpcnnine5xvqx +2sevenseven86lldmhf +8rqhnhsrcjnfzgpcclrmnlvbphrtgchpls9 +kxeightwoxsrvcbzhhbpdlrt22fhqfivefptwo +bdseven2hnqccjqgxjvjk86xvbhddlbx6 +zszz4kqtsqjfpqmcxbndmbdseventhreeeight +fourfiveoneseven83twotzblfpldfq4 +tgbxlthreezdfspjsnhrmrqxqj6cplcczt2pgsbfczn +jzdkc6xfmhpqstvzzmvxk431 +7eightqbxcnsgxm +5sixeight +6sixvjstz +4trxhdlkzqvjpzgpvfp1 +sixqhghvddcdn7blhptxp5htcf3 +nineksjvmvc2 +41krm9 +nine42sevenfive2 +zfivepkfqrgpkmxbmjbq6tgktpvnjvdjzsd +gssrnnqmm7sixfivelklmggxgkdtlmlzqp +64qsevenftmjzgs +6nctkfbskghpqr7 +8nine3 +hkjoneight6seventhree9 +11nineeight9nine +845fouronetwothree +pfhb14v +three21kdgcplbzzbeighteight +4cszltd7ninerrmhjqmtrprtccpjnjgdbdtwo4 +five96 +2lkfbsnq64three +srltvpbgnxvlksmfzpj2 +four9tpjvhhpsctclzpnsr1fourcttqvng +gpjxncqsbp46vb9tqgnninetwo +four1four +6dtklvddhlprphffpnkrksfseventwonek +eight4seveneight2onezfbnvjplvl97 +7ndvfp8qstcjdgzcfcninebj +9beightbsbphgrnq1ninesixsvthrx +bpxthreezkhjleightsbxmsdeightseven4 +fivemlfsninesix1nine6six +4fivethree3qtqsbscnc +four7dsix3kfhrrgbbnlzdfbgxsix +hqckztqxgxeightkfmvvjg6tp4nine8 +tmgfmcl2twonedg +fmvvcsix8nineninepqdrcmhdzsixtwohcnrss +nine258foursevensix8eight +8q +pqjqrxnine2one +9sixpbxr43sflnine3 +4onethreeonefoursixonefour +1vnscdrnnfpkrj8mndxbqdrckzgdpnfdone +threeseven7six8three3six2 +jvt24pjtnxdcpsthree +7nxfpnfzrssvqqcnrjnine47 +cflhgfournine368 +62srjsxgr +mnsix6fivefourjdnqfgjvp99two +8five6fdvgctwoeightcsmspmxmbgjqzjhlhb +seventgcdvchsfivefour9nine4seven +bbzvxfvmxhqv26rp5 +2psmsflpgqmb +eightnine4threekgfjmhbkhtxgr4threekxnmspvbfs +seven9two84phzrrvftgpt +xgpfkphfchzptzvconetxcp3qdmdn +five2fddc8hdzrzgcgdtonesix +one24sixtwo +mxfltrcltqjmmtj4psbf +jbrskjdtthvksk9mhfxjgdjt +four96njn +five8tqltpdxrklninednqkmgstlptpjhqvklnjhrvpzvpfr3 +onecsktmkt9 +seveneight1 +nineeighttwo1txhjjkqzqtnine +37onegfcf253 +4ninethreepndgnfqpvqzxbxkpgp4eightwozg +tfxnx999864three +sixthree19 +3nineonefive +rpht1onetztgngmeight +9928two4six5sp +gmhtwooneclqfdqvfivefour5 +two3dkkfive +7four6pklfxjqhgbvnpxmndsixthreetwoeight +5eightthreeseven9 +9fourseven5pmtcdpfvhjj +24fhbms2sixtrjtm +seventwob99 +3mffcdvdqsixgxtbrxqddkrzclz92 +5fivenkmtgbsnsixeight +3seven9hcbmcnjvqfour7 +bvspr4jhjlnddp3eighttwosixfour +kdvh5 +seven7hvcmdfkfour5nine +1ksqzfnmhfqjjlklptmmpvxnine6 +fxp7hljzvndnd2mpqm8 +86qxntjqmljdqpdbftqfrfiveninefcxzdqctbjppc +one62 +two23fivesgtsqpjrkvlbrfknjgcjbt +29gkcpcfdlm3 +ninehzvhg2one +ljv73tpfjvbhlxnpxqxhfivefivezxtzhlfsc +three7637 +rnmkzqgtjpfbn3nine8nine9ttcsdbr +jqtwo7fourone7dclxtnlnthree1 +872fivemjghskxcxmninexljstpvb +9hdjtfkqsb8skkvpfpgqlctvlz +nqnltrnsevenfbsixmnxrv87ffsjn5 +fkxzbxsbbfour17fivenine424 +ccbrxlskjzmrclgchlxlcpkck2 +one9sevenjgxrk33twonepjs +5eightthreefivethreetwor +zxqdnhnk51 +two39xctxpvsmfivenbtsmpcg3eight +three52threevgj8 +1twom52 +3pthscht +8ninegx3f8 +lzjvthree96jgfhfvsbv7qfour9 +threenineeight722ltvvxhdczjfivedcxbst +fourgvlbxrone8btblnlbkmx51 +one5nine93fzxthreebzchcqjbrxxct +3sjbbtbpkr1onectngpqpdfp +5xdgpgpm +nine9onev952 +fxc9seven +fiveggdqqlspfoursevenfour5three +7ninekhxpdgfive +3fmkhhbztk +737 +3kx2sixgrgslpfvvlfourfive7gbk +1rqjxnfmzkvxxsixt +fiveszkkmrtrctjgqvcfbg5r5 +6onefoursixntbbrjxfrfournpjbgcx +sixgpbbbkhxdj4skfrvnnlmmhxcpfnxfive +two37hjdklhtvtwonzhcqrbfv +eightsix7 +four9253njcqvvhtgs +fourfive3bxnvck +ninelsrbgctxvn59six +3jzqb7six69eightonenine +73nine6tkrqsc3kthjdmdtmsixspvvr +8691twothreeeighteight +8ninetwo7nine21qpkbml +3lttttwonemh +8eight9onefpscrm5 +qgl38onevqjbfldcg +dbcxgcfsf23jbb6eight671 +18pzgfqjsfourthree4bvqtxsh +fiveseven7mdgmsbdphthreefivedpzjbjc +7onemmspfpbfbftcpgvxhmh944cvdvlp +96hpgcqlp8six +two5jrrsix4dktmzkqgvb +two93fourninekfkkgdxbvk +93onesdnxqtwo +jxmfmmvlxzseventhree5sfconeeightkrzdcvnhpvmfnz +86gkxpqspnxs +seven9pblxnnkkjffournjlkgqmonedxqseven6 +jtddqv7nzpsixseven +vgjkbfnc29gskmmjmgsrbvghgrbtsbrdglszsix6gm +gjglfour8three7five +seven8ninetc4foursevenxfxlvmt +sevenone21nine +9onefouronevqrsthmlone +8threemsrbrchmk22fivepjdxprpvplt +rsqkrlnfpsixfive3three77 +twoeightseven2threejzgzmzzgqdrcmf +three8lsctcbnhgkpr3 +4ktrtzn +vqhvfxrxhpdgqhcrrczjlmhdnlzseventvtrrktd9twonenqn +twonineeight7 +67sixeighthvfkjhtj5 +644 +onezdfz6 +6qmcd9ninenineninetwo8 +four7nine7 +4hjnndn +1fqfqdqqxdnvhmqcp8 +rrhndnbpjjzhclhv9ppvlbtxklzfivejhxzcbpmd +six7526 +8ninefkhszlp2 +fivesix34twocg14 +3sixfive +2nine3 +2hv4rrfh3two8lr +sevenrqbzmkmcn22 +56vrglvbcdtxxrnjrlhpffr +mfddxflkqd4six +bfsfnkqxc76rtpgss3pkqkksrcxnine +83fivemnjdfnk85zqmssgfffourvgqjbn +822 +dvxgqrbjpnqvpsfthkz6 +4fdlzcxeight8crmrztfdmthree7eightfive +two9threefourtwo8vj2 +nine1jxpclfhj +jrgfxlgblzqnr9mnfrcsixone +5t3nine5 +twogxssevenoneseventdc3 +rvzcbtwofour4sixgfzk +six22eight81ninepnscnlv +eightfiveeightsevendxx1gh +7nzlpbx864g5 +hxgdrrnnsix1sevennvmsvdvccpmfive +1threevz9 +36eight4xvnrghgjf996 +nine8mmtqkffkthree8xpmsbksix +1fivejrgqrjjnql2dvmcqdbjbsix +15fiveseven1td3 +kmfmbhcmf62five +36dxfoneninefivehrr6 +four54sixfzhq26 +1427qjseventhreefiveqhv +eightghnnlddqdpm1 +9jbcfdjzjxreightlcpmdddts +6ninesrdgkrfivefoursckkrfrpqqhgzeightwoj +xmqsnjgskfour8eight +9l8one +four9jghzbrsix7seveneight4 +9tgsvk +sxgkkbnlsbnbbc2ckqhzgdlsbhp +6ktwohsvbeighttwo +xgfrrnrlkgdqfxdtwo9fvthree +5hqdvsdnrvr81sixsqjmbdls +kkghseightsevenmtbtvplcjnqtscx6 +rveightwobhqtmjhsrptpzkbv3ninem +3qpgbd2fourqdsnnbgmnsqgdb4 +mfive12 +52xqhpfdjgmeight13tcn3four +6lkgjdj +rvsvpt144lrtvrtpvd +8fourfive8 +28dhzrtfcjlgchxbthree +vvsixtwodxfz5six +seven7rcp7 +threethree136gts9threenine +9477 +seveneight8gmhthree8 +nn633sixzxcxthree +two95rfcffourtwo3 +76nine +cvhlpzsbmknkqpgsevenlkzvm7hnznjsbszgvxrmdnn4 +pnlqmxlmvkkpdgktwo1four41one +4hgnhzkbmlvkqpqqptd93two +lfsnfs7eightvdnghthree +shpndlkr7five1three6 +sevenfourfivesckjjlzgv27four +xhtpxlqssd3eight6two6 +48ckzhkk84seven1ggsffz +33rqthree6jvqlbzllz +4jfourthree6 +jkhflbhqhtmpmhmonebfbmcmczbspj9sttmnvnvgfivekz +eighttwodk25sevenninenine2 +oneqqxfkffivesevenzqhvjtgjlrninenine1 +2nineseven82fivethreezzqfjm +mh4 +3tjfmrtnff498 +five7three7three52eight +jgrndnjckvc1 +9sixgvv +six3rfpxrl9three1chczskrxthree +6bjqqzfqcxvnxbkpq +922 +loneightnznrcpd6cpfsmclp +7five7qncxmfhleight +bhsgbsdnsixnine4msnfmonerjbpvkqf6five +4xrcrrllzh9two6zgcftpfqj47 +six31two5fourthreeeight +gqhckrzrpltwo72znb4oneeight +trsxcpls3pmqqrskpmfivehdqrptvdtq +six3four87one +46two3 +9fiveseven57vhmq +jkrbkfsevencnvzp89vhmsdcfcthreetwonedrl +9cvzvqfboneffive6jmnpjkvrjz +82xrqjdqchdbvhxpninefourdhb +3bqsrf +fourtwosixsevensix9threesixthree +3fourkgjbxbpsrtgsmgrjthree +ndeightsevenfourtwo943 +471pn6 +bpstsix84four32 +gjkcq89ninegkckjpkz +eightkgvmxlzlhrnrdpttdqbthree117 +vtdnlkqcg65 +btwone727onesevensixkhbnkvtlthfjfive +twozspnzkssqseven413 +7nttlqthreenspcdrhdpn563 +six3nine +4twodkrlmssknsgfourkcfrxskpntnine +qgtgfxhfjj3pslzsttxpfive +fivethree9ct55sevensix +8twooneonesixjlszd1hlhbcgjf +fivetwosixsevenmrzjqjtfourmrk7two +pfnine6sevenone +3threex94znone96 +79two2sixeightqmnbxcxf8 +oneeight5 +763lsdvlz24threed +four9oneeighthdcrzqlnvxj6ninex +7552twojhv4 +3rzxhddcfxone553one9 +sixsix8 +7seven26k +86onethreenine1vlnmvghn +sevenglrmsnngpf3mfblll3seven +npdrbsxxpcpc3jzlpljsnlsrvdmvtr6one +6894one +rjzxs7 +7mllptmtwoqxrpgprvqrstmvvvvm +sixone12 +225 +dcjzmcnbpptwothreedzqctmhm4seven3qhnbn +oneone2six56jsmdjqcznjtwolcjvmpkxlj +2sevenseven +7cpnpkcqsstfourjthreenbzvrdgeightsevenhfnztth +4phcrvcgseven4njn4 +three9fiveninefdv +63ll +9sevenx7 +9fivehvtfdckjnpvk +gpkhmlrxs5two39 +kfvqv5oneonefiveonethree5five +2mrjctkmlks4z +8eightkrzkdxvrrjvtwo2 +fiveninesix9 +rhtnxkvthkpbqn4mtgtdnmmxmvmmzmcbt1 +mtwonexdljqqgbbnineqrgbqnqx7eight +fiveeight8sfvzbpkeights4 +8threesix8two8hszvhcbonefour +tpjtvpjgtnine2rbbfd +zrxjftfg4b6three37four +th5kktbzgmvkxhhcsqcrvtldnldml7seven +4txnqnplsixzptgszd +gzt5threefiveninetwoeightsevennine +jtfrlffv17268 +qfour9six +49vrbpqkkzct6 +14two +nine2drdcd7sixpfvsblcxqsjshhg +5onehfivefour8mnine +5qlthree6hbkktrpbmgninepqtxq +three8four +ftm67qrmsix +seightwoplhzgbvb7275 +qnqtbdmqd4 +onefive2lcrdjrzbheightthreegvc4three +87eight4fiveninefiveeight +1seven7eightfivezqcndfj5cmblgczd +seven6rkxsvbs529fbgbtclkjhcljpkjbgmvz +1twojxpxrgvvzq14ldngl9eight +qkg2fivemrlzlhxxzcmfive +one85four9six8eight +7sixbgvdf4841 +hktntngtlfflzrdpfourninevlzpdrngvchg2 +6two115 +fiveninesevenqxgjrnk3two +eightthree988nrclmr +2one6 +6737jfive +8four3 +4fivesvntkxfpnqhone94three +7six1twothsd86 +98pczqhlqbzjlvfnine68 +xtqtwoneeightlvcjqfourckfour2nine +9sixllhhqhfivemmoneeight9 +4czj3 +ggdlxrrxjl1jnndbgbdninesbcfhd2five3 +kszvbdfninethree5onevflrqffxmdonefour2 +1nkpmvbf75 +lnbgnkkfhseven5zfive2qcr +seven75xcx +2eightbzsp2pfg7eightv7 +fourone29 +4two5two9xcpkkjqxcfivessqqvhbbt +ncnqg1sixt9ninedlfgsqhnxx6 +xrlsktwodnbcbonefvxxqgbrsdthree3seven +klvsv73 +onezvbhrblrkzcrsevensix96jnpxjone +nine6chd4 +bdvkqlrh9eight6eightninehq7 +fivexpx1vsrreightkp7dph +3eightlrrlgck967 +xcntwone4633sixmkm1nine diff --git a/2023/day-01/src/bin/part1.rs b/2023/day-01/src/bin/part1.rs new file mode 100644 index 0000000..3fd213d --- /dev/null +++ b/2023/day-01/src/bin/part1.rs @@ -0,0 +1,44 @@ +fn main() { + let input = include_str!("./input.txt"); + let output: u32 = input.lines().map(process_line).sum(); + println!("Result {}", output); +} + +fn process_line(s: &str) -> u32 { + let mut string = String::new(); + let iter: Vec = s.chars().filter(|c| { + c.to_digit(10).is_some() + }).map(|c| c).collect(); + assert!(iter.len() >= 1); + let chars = [iter.first(), iter.last()]; + for char in chars { + if let Some(c) = char { + string.push(*c); + } + } + string.parse::().unwrap() +} + +#[test] +fn input_1() { + let result = process_line("1abc2"); + assert_eq!(result, 12); +} + +#[test] +fn input_2() { + let result = process_line("pqr3stu8vwx"); + assert_eq!(result, 38); +} + +#[test] +fn input_3() { + let result = process_line("a1b2c3d4e5f"); + assert_eq!(result, 15); +} + +#[test] +fn input_4() { + let result = process_line("treb7uchet"); + assert_eq!(result, 77); +} diff --git a/2023/day-01/src/bin/part2.rs b/2023/day-01/src/bin/part2.rs new file mode 100644 index 0000000..5185b76 --- /dev/null +++ b/2023/day-01/src/bin/part2.rs @@ -0,0 +1,86 @@ +use std::collections::HashMap; + +fn main() { + let input = include_str!("./input.txt"); + let output: i32 = input.lines().map(process_line).sum(); + println!("Result {}", output); +} + +/// Return the position of `needle` in `string` +fn find_ocurrences<'a>(string: &'a str, needle: &str) -> Vec<(usize, &'a str)> { + string.match_indices(needle).collect() +} + +fn find_min<'a>(matches: &[(usize, &'a str)]) -> (usize, &'a str) { + let (position, word) = matches.iter().min_by(|(x,_), (y, _)| { + x.cmp(y) + }).unwrap(); + + (*position, word) +} + +#[test] +fn test_find_min_1() { + let input = vec!((1, "eight"), (2, "eight"), (3, "2")); + assert_eq!(find_min(&input), (1, "eight")); +} + +#[test] +fn test_find_min_2() { + let input = vec!((4, "eight"), (5, "eight"), (3, "2")); + assert_eq!(find_min(&input), (3, "2")); +} + +fn find_max<'a>(matches: &[(usize, &'a str)]) -> (usize, &'a str) { + let (position, word) = matches.iter().min_by(|(x,_), (y, _)| { + y.cmp(x) + }).unwrap(); + + (*position, word) +} + +/// Return the first and last number on `s` +fn process_line(s: &str) -> i32 { + let mapping: HashMap<&str, i32> = HashMap::from([ + ("one", 1), ("two", 2), ("three", 3), + ("four", 4), ("five", 5), ("six", 6), + ("seven", 7), ("eight", 8), ("nine", 9), + ("1", 1), ("2", 2), ("3", 3), ("4", 4), ("5", 5), + ("6", 6), ("7", 7), ("8", 8), ("9", 9), + ]); + + let matches = mapping.iter().map(|(k, _)| { + find_ocurrences(s, k) + }).collect::>().concat(); + let (_, min_number) = find_min(&matches); + let (_, max_number) = find_max(&matches); + + (mapping[min_number] * 10) + mapping[max_number] +} + +#[test] +fn simple_input() { + let string = "onetwo"; + assert_eq!(process_line(string), 12); +} + +#[test] +fn overlap_input() { + let string = "oneight"; + assert_eq!(process_line(string), 18); +} + +#[test] +fn example() { + let string = "two1nine +eightwothree +abcone2threexyz +xtwone3four +4nineeightseven2 +zoneight234 +7pqrstsixteen"; + + let result: Vec = string.lines().map(process_line).collect(); + + assert_eq!(result, &[29, 83, 13, 24, 42, 14, 76]); +} -- cgit v1.2.3-70-g09d2