From d9aba1bd1fc9d69443763dab414fac14b0b25056 Mon Sep 17 00:00:00 2001 From: Brian Buller Date: Fri, 1 Dec 2023 04:18:57 -0600 Subject: [PATCH] 2023 Day 1 Complete --- 2023/day01/input | 1000 +++++++++++++++++++++++++++++++++++++++++ 2023/day01/main.go | 97 ++++ 2023/day01/problem | 86 ++++ 2023/day01/testinput | 4 + 2023/day01/testinput2 | 7 + 5 files changed, 1194 insertions(+) create mode 100644 2023/day01/input create mode 100644 2023/day01/main.go create mode 100644 2023/day01/problem create mode 100644 2023/day01/testinput create mode 100644 2023/day01/testinput2 diff --git a/2023/day01/input b/2023/day01/input new file mode 100644 index 0000000..07f31a4 --- /dev/null +++ b/2023/day01/input @@ -0,0 +1,1000 @@ +five8b +2733vmmpknvgr +3oneeighttwo +twofourfive485 +2fourghsixptk +5fivezgfgcxbf3five +eighthtkk5 +qjqpnfs812sevensbjlkzrzczdmsr +cpxtthree14 +pljnzhchrrqvkncfnfive6four7dzqkfslm9 +dlrczxpfxp1 +sixsix35 +twoxldv5rftbpfivevqtphhxvgzkhbg +zsjtsvjtlrsdsvqgfouronexhnbgpsl8 +five813 +53eightfourlseven5bvtmzfkqc6 +51two8eightseven +frfshfjvlhgsjvmxbplkmsm1seven +lnlgcc9seven +one52qcfdljqphq643 +three78sixtwo +czrpslksggspckxmrk6 +five94rxvhdhqh3three555 +2twonszcpthreeeightsixsevensevendbllrvdtqv +smdn65foureight7fiveeight +kpdxkc6foureight +tlmjmg634nineeighttmdgqbxpd97 +sixseven9jgpnxqhq +seventgb4ninefive29twonegnb +cnine1 +zhsbsix7lfcxhvcmd +75seven2crtj +two7eightfivefiveonejlnrzlnhtvjp +fhgnrckhgdcnbmfmjglkgsrxprk38dn +threesixsixfive8nine +foureight28five +nine32fourh +nine27lfxone +pkrjhx99fourhqnp +preight2sixheightfour +12eightsixnkhb3 +72ninelgfqnczgd92qlzqhghrstxvgnbgvp +eight3brhd4mrnrzlspfivetwo2 +jsqsvzpdzdthxcv8three2 +fmltrcninejhtwo6twovbglrvkr +fiveqtvbrzlqtlnflvtnqpjlrtwo9eightfourqlstm +one5684ttctfbcxzq +2four5 +8qsjc45eight1fhglfqdkhqqszsptkqvqpphttq +hbjb7mcsx227twomdeight +4zbjthree4twohlk9 +dcbcdsrrxfxvnineqsixone7gmspcc4 +twoggfour4 +rmz6jl +zrvrqqlnqd718sixjeight +zlklf8sevenqcdgxpt2 +one8four552677 +1onefive1zfb7 +eightfourxrzldsqgbsrgnlvshv3pprjpf +1four1rsvrlzjxczrtfcjj4onegtfqhv +jdhnblrs8three1two +mdvs1xvsevensixsix +89gqxxczgvtzxtktwothree +sglmqx83zzfkeightsevensqnh6six +ceightwotwo7oneccrjqnthree12 +one1twoninehm +98sixhrrjld8 +5one3 +fdlv8jmjtgdfhskkpbmzkpbvfivevlsbrgfxpq8mzdnzglf7 +rzqzscdfkvvlkzbsztsevennine9ltqccpfvfour +four26kkqkkvjp +threeqjlx98twozq +34msvlqmzqxmxfourztmjptv7r +four7ninefourpkpgvqhtwo +sevenfive8ghv8khbqmknpjqpsh +leightwo8fnbgrnfjdlthreesixtwotwosevenlxqgxgnksn +ninefivexrxrh595hjqvqtcmdn1 +twosix8 +zsmcxcbvhmdx5three9 +dqjlmrs4 +2twovltgsevenfour2eightvkqrq +fourrbbxkfjjnt5sixxfrdmkdtnmpz2eight +six1eight6bfvpcprsxjcffql +1hjx2zn8bqkxkxvone +jfdtpr6ftj4sjzgcfdq865three +69gzmpncxbsp +two4sevenzjtncds +4sixcrgdqxd +4mfltwojzqxvtfxlf3 +6tgrsm3hzvtvjcz5tfmzmjt +2sxnbzgmdsmeightvdlpvvb3one +lqthreecvlddfmx4two5 +shbrqnstvnpjhjbxslgvcfmn33 +six5rb33zlklrnjhrpsgdppsnine +tmjdfvnpkmlqqzpqktwothreefqcvvmhrzc8seven +nine7twonxvvhgpffx +fv2sixtbtjf9frdbsstsbfournxctpgltlq5 +fourkzxttshmb3dddbjxbnzkeightsix6 +four9sevenrgghlsixxgllzonegkbfjcjlk +5sixthreedjchvpqeightxhkgbjcmmhgszsrtwo6 +5hgkfhkqvbj +xqrxqvbqtwofive99 +fcjdklhnfqxsvgctqf6pczht +ninesixeight5sevenqxxxlctfourfk4 +nine3sixtfqbrkseven6nine4two +qxbtwobxgcpncsjpbtbrknq8scj +6dbthree4 +seven2glbvqgzhzb8four9466 +49one5 +9zfktxzcjdbmqzlfhmzrxdvxfour7twoxsqr +77eighteight1 +kzqdfqbdztwoseven5twooneightf +t3tzfhgl5 +seven35mpcbfour1xmthflbs4 +7threeeight +pglxfhncrpqd9fourzfourgq9 +jzplksqfour9kpgfvxfivev6 +m5 +vvfxfceightd7tpbnm +rk27three4 +jggnnrbgkgjddmdjfleight32two +6p28cgmfsxhdeightxzgnkldhbcsix +9hfmhconesix +3phhbrlfsmqqrtkh15ppfjmssvcmsevenqgjvxthree +klmkkmpzm8vcpkxplppd551n7mqcjxcbls +7dpdxtplq8sixfive +5eightonenine +sixonefrmfszllmp3gj1995 +9one3 +2xnbvklmfive3onetwosevensix7 +9threethree8mcqvmflmp2nrsbzfx +xvhtwone9clh31htpg17 +7lkrbdzxt +5qcq5threefour +tppnmzgcmnined6kzxgthree3 +3fourqtbz +scncfqldeight1rjkrlrfcvsbmhqbphzmcvpmgffmone +slqhhldzjfdjzeightlskpbpcd5 +fourrldctfs4hj +4znkpxfkcg5 +554 +3eight4five1thnqtwotwopmtgk +six4one13sixfive +4jdjkltwonine7threeeight +three8three1 +9srdbvfndxptmsjpgljnqplpxnmvr +ccbxpltrbz3qbltj +four69lmjsjx74vxtzghkxnxndhpsmzrz7 +5qbp637tg9 +8rjknnchqzs +4twoninezb9 +7seventwo3l +6rsdpppmstqngdgkdcnsqcvmcqbfflxgbsktnine +nineone7one1jggrdkqrsv +fourrbznn7 +mcppjgfhthree7nine +five1cls62seven +dvfphntj2threelfivecjqnbj +dc46one4eight87 +76qsmlshcsfh9 +46nine +nqxdqpdv9ppgxhzk5one +1fivexsixthree +six3j3sevenbrffbhvznine +nzlkthggfive1brgnine5 +7fourgbcpbnnmgsgtwo +sixsix7dvmvhzhlxlnseven +24five113nzbpnmkknine7 +cntwoneninepdnhbttgtz1six91fjpkfjhjxr +2ninenvndrdlm9219eightfour +7five2eightcxqrjzc7phfvsrsv4four +xhmvpcngfivesszvgffflbcf8dndxdllxsix3 +48hgbzhonepftgrmnzqscvfpsj +pmsixgr1 +eightktmcpgrhflsix4ffhtlg9 +8jfvxmslkl +3three2six1threermckmmzb +lgphhh344eightkdcsfhjboneeight +xoneight2 +4rbzsevennine9cxpzmqcb +sk56seven1 +cmtxprpssix1sdqt +eightjgsvcgfzq829qnttmfgnk +68sevensixeightonemtqg1 +eighthlkthree1fourn +lmthreeone2znspdvbqt8 +nine73 +ninefive7 +onerfive1ninefive28zmxnlbbhxq +33nine1rmnmzfkpbrdzrsksg +4jxpfrxclone +gkmclldsnjl3kfmvpmzfpsntwovccpjxvbdh +sixrdxrprsssh45 +shjxdgtwoseven792 +53mkm +7psjpssq49 +prlv5fivep2bcqtscqgb1 +qbrcftwo53oner2fnvxlpsxz +fhxmhkdslfksktsnvhtwohkljsgzhdq8five +nmonesixseven5six6 +czhdtsixfivezrrdzmmftbtpsnkpfive2vzrz4 +7eightqkvstwonen +nine7threefive +jshmdl7oneeightwocj +jkfljpsgrqoneninefour5threeninekvd7 +khdkfpfckjdpcbnhzttsmnqprninesixmsv82 +sixthreesixfive99shjtllx +njkmzkntcffive8 +xqxvhdtkmtwozhdxqmsvbllsxm3 +zfz1eight +dcmmckrfdpjsflvgghzfninetwobvlfn24 +h9fivebhprlprpjt75six +fivemdlzgjd2ljprx +one1sixtwoeightlmjh +five59three +qhjdm2cjqnfgfive659two +vsgldkt1fivetglmfivejjk2 +nrvzbcpsrg6fivefivethreebmvtfkhztwo7 +9five8fdrfmstn +dntfgksixfourmvmqmzlx3vn +nine9twoeightonebz +6threez +cjeightwoeighthml1fivepjlxrdtg +4gglzht2fiveone +mllm95 +dsflzv4dlqthreersgb1vjv4one +qb814 +31jzmclxkkroneldgqhmgone1 +qgsdnqqtbqtwoztwomxbvzd3eight +52seven +twoxfbrpfjczfivectd7fourfivethreeseven +mhxtwone5fqfqrb989eight3 +mqmxfhnqh71bhlprj +cqcmc52one9 +blvcgqvj45fournine7 +lldkjs43 +jb6lrtbjqrqtv +dmrqx7onervmdzzvdbmlx +mntnbrtpc3three +4four66 +3gscq979eighteight +mzf62qncbzc27 +59pgftnpjmdjnine16 +41twolsfrnhlxthree193 +four5kcthtdq4two7twonejbd +b3msvvtfmm8vgvlcmhxrrxxzdcvp +twohlzrjv9xrxgkxjppd1fb +slrf7bxxbbdqdhzkfrlxdvsdsrvthjmpghltrv +fourgcxsvlllrh3 +jgbgbjlvt78mjhzlvfnszt +678973 +8bfkv +73tzgxmvn9one4sixpfzone +13lcvvqsxthreeeight7one +sixninefourgdvtdbtnmxonethreetwo6 +mbtdrhthree49fivedjqjkvhhqt +vvrqjmzfgqc6qstp1 +1eight5hjm +fivelqmvllsxdtwothree4vtcrsxftpk9 +fdkzjlbpbjzhdkpvz2 +sixfour5four +threetfivethree4 +sevenseventhreejxpkcznqv1six3fmlh +2dntmqzdmthreedjjqzrpgjd13eight +1gmnqhsrd +138gzpkdhsnz +c5eightmfhzdhmzktvgpn5five +3twoninetjpgtkznjg +28khjdn +fmgpdjjsix6cfppzrltksixvgjzgddbrz +zhrcpxcttrht7sevenxktt +fivenine289 +sixeightgzdgsshzjf37 +8tfmz2 +8three3sevenrcmq9two +8eightpxfjvdh4 +8two8znfivextfzfcsix6 +8twothreeonenrjshv +4fourhvbhkkdk8five1 +5tworhmrleightonebddccdfive5fzgkgtmnx +79 +6jlkj8one8snfgmqjm6 +eightv6oneightcd +fourff7fivehvrtnbjxgx3ldmvbvpdvg9 +fivethree33seven8onesmmkhkv +dhbfqsixhcseven82sixeight +pkmp8jscpmmscpz9six9qbjtdrpxheightnxssn +757j873 +7fourfour +5lpmqgh +5sevenvgzsjxtxninethree +eight8scpxgkkqh8 +2three641djgxmrcgjbkbhjhkjzone +8zmgtsxptnfb8zsgf8hfc2qbxhl +3mlpjfggg58qzfivegdjd +rmhnkdzzvtsixfive988z +pcmmscdhdthreedxbx1vdvnfgz +twoeightldjzkmcsdxfq2xtxhmjz1 +1mdxbkhtq1 +gkndvrone2 +vn778jtzknine +5chzmq +gqlnfnjshhbdglone6two +sixeight2eight1 +ninefourxzxtbjk4vhpbkk8eightdddkftrpctwo +gdzqhdnm85249 +94qqmhtkznqk +bqkmflvrfqqxtnbnhjqtmdqqq8 +mb7fivevnhsixfd6five +8tdftqnmxrkskqbrvfqpvkznine5 +ninelvvlvzmtkrqv1onen +bvtdbfftvckrfq8rbnbpeight +xlthreetwocgtfhqdkghvhb3 +6kxpgh +1jtz18five +9dnnmmlzzdnzjvsixsmqkcmrsh71nlhkxbhcb +ninemjpfmbxzsfzrvxjeight7pc6 +gffqklr29sixeightkqqvxhfivebm +lmqqthreeone38five +eightonenine8two +twonineeightseventwoeight451 +hjxvpfqqcbcqxhfffrsx49zvjfive +eightqgknnrxhthreenineeightsevenhpcrg2 +5cqncjbtbr +q9three6lpvvd +77lpsmgnbrchx52nine7rvcccdzgn +lveightwotclgpkdmqd3fppxzfsfllftfpsrgz36cnnlcvqfdjx +eight79eightninefcmqqsnhzg +ffnpmkfvsl5jthreethree9three +3tqvn56four97kfcnine +1xqonethjrqhjfour1hjmxjsgqs46 +onehgpdhvthree7lkjthbzncjeight6ftps +2one2 +two31seven41fourfive +7sqklmxvrn9873 +9tjsfgp5 +49sqsphzttrqsfbzcfqfcppr +sbvzgsevensixhxfourxlqnr677 +two3cmflfbjzzfourseven3 +fivesevenfivesevenmjgnmcxqz6zxfkbrzr +qfqcxpcbc21slllgbqnd2 +eight8hhffbdpbseventwonlqqczpxkbxmg +79fivethreeeightonesixeight +3six4pghksgpf +1four3nvmpdzrzv38 +nine7nnreightghpmznjpgb4sevenqnjb7 +xsgoneight6jmrxxbzsevenkkdkcbzq +ninehblfhqpjkeightkhrvnznbthree6three +ctzlzfourflxfpftpbtwo48 +qxtmjtx8fdftwoeighthd +sixqrjqhlxkthreeghxvftpg9fivebzgfnjbqksvl +vtgvonebxprnzxdjffnb4nineone2 +68gxjdeight7four +zbcvxfive7seven6 +eight9v +kqjzdszpbvkbhmbxjsvfcdvzvj4five +7vkpbmnpsvgxqtjqcmrcdf7three +9threefour9qkkhcvqltwo +threetlnjfz9v9seven9nine +91vndvtbrrgtqmjx +2rnmmcl +9clcggdtwojgjxjzshfourtwoseven +onethreecxglsmjhninecs3fourrjjnt +xptmdvthreefourfive1 +xqqsrlg2 +gpglf7dlrvv4seven2 +6zbhjvh7nineeightseven8njm +sixpdmpninefoursixhsrcrfrkb7zdkdjksps +five3cfourskbvkjfourjvzqrtftthreemlpfrtks +threekplmfj4xxvpndpgprnjqqj613rntrftxkn +tcpmsix6 +25rcqknbkm5nkqsvbcdthkqrrg563 +73cjrfthree1fourqkhbdhljnshzxq7 +onejzk2t4nineqstdnhlqvmrrc +vx4blonekjlmtx3 +five6213oneblzszq7 +seven7hztfndvtnroneqh +four4hpvlcjk3mskxtlxpmgcxl92 +five46 +8mlkrfive +onevpgxlone23klbndxgjflrf +44qksix7397 +ninegzkthtxsvspqjh2 +zmfhp7bltlpsix +eightseven9vrqkffivefive5 +qqtz586zzldcpvnsfourjjhb14 +sevenfourpsjvxmlklm27ntprvd +1one941zrrjrrjd +sg65 +24mninexjvjsone +56cdtwoninegpgvvnbnn +29oneblxcjdpnf87ppmkkm +9six8skvxj1zcffdbxtmb5three +335cdshffffninenine8 +three8five14twoc +seveneight8 +bmltwone8qtsnrqsrtwovbzkdd +sixsixtszddt5ntlzkdxonertrcqbsix +onemt59 +ninedlpqjfbfourms3qdsnztclcssvfkqdpzg +kpvplnbcx8 +fivenine4threesbrdxsvseven91qzkcmv +6ckhone5fourzlkcmgj +sevencvpmmsmtrlxkbng7seven +sixdx23gmlzgvgd +2mjhtzspr4three +jqbhfdszs8zpnt2cqxgmpvtpj6nine +fourgpcblx8 +zlmmjqzkdqtwomzvjcffzl66tjsjsjlnx +grzfqr61nrkrndzgjzdq +dnxsevenmkfour8fbfttwo +pqlkzztfnr8fivesix +7five4seven9 +c61 +four3pmhbpninethreexttrglk32nine +1lnthree3lngqhxcthbvgfiveqnsfn +five3onesixsix +11llfzpmthree +seven64 +2qmhjqlkj1tmjqtgsf +bvkcgjcqbfnjrgsix5 +gjvjrdrz6jmqmzcrl715 +72seven +14nine +fourmpdbjqnnhjpskvsncsffpkronefiveeight1b +eightfiveonesevennine6sevenqgsdjjcpf +sevenfour828 +n2nine58 +zsrkcmfivenine51gxjqhlrlffsix8seven +3two2 +5sixtwo2 +fjjkzlmzggtjsix86gblbjttfz5flsgj7 +ninelkcddvxlkg7xrtbdzfseveneightone +53eightg +7sevenlgzxdfchone1 +1xnlpfjxveight2one +sevenfslkzl56 +83eightfour7 +35sevensevenqsseven1 +6eighttcgnbfourone6fivepbjn +1pqf4937four +six5tvdmcvrdqthree8kdnrzchlncrrqdqfive1 +qvszbjb4 +eightfivehxrhxtwovfxqhgsmrnineeight2one +8sevenblvfbtnkzpeighttwoeightone +seveneight6three +ntdvljbnsevensix8rqlv +one6five9hljzglmxtmrtxeightnine2 +kzbdsmblmxklrdzr8tsqtm +fivetwonrtnineqpljsix9 +sixjjlfmqrsnineseven9trm9qnqkznmj +6sevenonegk +fpmvll8qvgqknvksv1five +18eightninebbkhcbpddqone +one3two2lcbcvhfive72 +sevenpfm45cdhknmsllndvlfiveb +eight5five1bzlpmqvrsmnzthxc6 +ninekcvdptqxfd29seven73two +four3ffhkk +51five +8seveneight3mjjjjlsjcnbrrk8 +1nhlxvsbsix6threeeight6oneightzx +gtggvtjfour275two3hjcxzxbxcph +6four9f948fjspcvks +1czxqfj35sl +31four2eight +7ftjq36one2 +eight2cfqvqprqmp838hsgmxxv1 +fourtwogtwoone417krzgmck +three9fxhpgkpstwosevenoned +tlmfhdzxnd862 +twofivesevenlrnqcqfkn1eight9bxznkm +one74hlfj +549four +one37222two +bdmhxnsfourppseven6one +nine34lgmjttkr5915rflhphdx +stzbmlshxl5rmxtckrbnsnmlnine9three6 +9tmbfknqj9three9 +eight1fldgfvcxnltp49two +hgxvcgrdxl7zsfjn6fhfnjb1fcqkzjs +fourfive226nine1 +rvp2six4two +zzntwone5three +86oneeight8three +three7foureight4three1two +1fivesix6eight +ninefoursn6three +qmtpvccppsix4two9fiveseven2jjpjhlcqjb +9four6eight +gvljsfpgqf36cqkdrxxngldqzhjmthree +sixsixsix9rslkbnxone +vznttvmkp1eightkbfk4hzlxl5vpjtch +6hc2 +1threetwofrvpdnxrsjmg1nine +tpkmbdh38nineeight +four289 +8418seventhreetwonehqc +jdvkncsfg1qsdshccmsdsbjhnc +lgseven1sixgtzlcpm +seven23eight3 +sevenpmrvkpvhhghp4fivejcbxzkbr +zfgrcmm29vtrgfive +kcrlqtjhfb2 +pmrone1xrvhninemhjtnzm +mmkfjskbjg216rn +hjgpm2 +tpnrzkseven9jjqq +onesixnlkllkftgcdhltschkxkfour87vp +8gqkngcpvtfjmcpzfour +11seven9zzxnxbcxfc73pzjrm +3119two +jzglpbnhonethreerq7 +321eightddjvxpdsllfvseven4 +lxgcfivesvrzrjhdrbd8pqgdqpsbg7 +xxrnsgch7nine +9eightjpdqjghnl8kdfhdveightbmfff9 +two6sixxvgcpxgljxkg +nztwo9eight +four1ts +9sevenbmnvrvcc3ninefive +rnh1sixrlnmmh68 +2onetrponefour924 +17xfcstkfxcxnlvvp5fltzqcksk +jlvfgxnsix5 +five4threebcnthgxvt9tkmfbqqs +eightsevenone8eightgtlql4eighttwo +4tzzksevenseven9f2eight2 +7nlbrzdpdp3xhtcfourseven7ldftbnk +ztjkcqvvseight5fivesxhbscxkmn +fzsmlqgntgmgsc7hrtvxfivefive +4threeninenine +7jcmmqbtcr72 +bcnzcgrk12seven +jndhc29eightnine87dljpd1 +rtppcrnsix3232four +dh2sevenhtsplzkf +one4five +47ldxfkcnqb +kdfdbcr2two3nine +5onevczsxpts7nineth6sdsmzjfc +ggzzzvjntb38glztdkkk +eightflzftkvh22nrjmpznldhsxhqgkdq96 +rthreefournine2xnndn +8fivedvgqgxseight456vgnfnvpjgq +eightgxkdqqh3four +two7jsd966 +seven5fiveeightonemttgx9eightnine +sevendgkzmxctwo1threetmgmgnld +rggjkbrjg33twosevenrbxxjnine7 +onesixbxnpmhlthree4rcpbqkhq5qvtq +33q +sixdbcxqztczoneskj9mclf89 +zzsoneightfbxknpdjft926foursrvdk +pn379xlgsccrprqbnfxtfour2 +4nine15pjvjg5four +3onethree +4eight7dvkxmndk6 +8kvtktvd7five3skvhckqbnh +x3onetwofrbqtgr9bgkkpqvjs +ninefivefour93crn3four +zsglkfdp8six5nineqsrfzqg +nkrkqxgfourseven73 +5eightcllxmbbpjxl +four88gvbggjveight +zgjh6cznbfcsmvmzrcprdnine +two48ninethreekdtdqlthreedbmjxbpx +fivegnsrlgptrxkqqgdp7threeeightsixqtfqhgmgfc +536ffnineninecmfbbfmxgfivefour +7sixqndfhctgckxdr321eightthree +mpjftntcff7eight +twosmtcz7kktnknvdlfjqr +four8bpczqzzd4zczseven1 +xbkvkbqgzmhgsrsqbpkccpthreeninetwothree57 +eightjqjsixtwo4 +nslltg5four9seven8seven +96six +jkmxmqxgpxc2s2sl +17sevenztsgjd92khrbcg7 +2d9cv +three1one7oneht +1sevenkrj482 +3jvbfffivefive +pkghg878 +jvqlffztrn3nine2nine +sevenpgxdmspvptwo8seven +fiveone58bzprvkvjt +vhlhbzvtd1mlnineninethreegmvkpb +brrmhfvone4oneeightsix +57hmbpznzlfourfouronesdzsgnnine +tth9gnonesgbbjppfqsevenmgcbxcm4seven +twofive5eighttfgxgfptbtmgkngczkfsn +drzmrp4qjzjvhvn +five23nfsvnseven4 +eight2vhcbxpbgrgb6nhpcdrsfive +5lg5483 +foursix4fivefive +6l6 +2rhmbmlxc67four9 +kkj1threelllbckpmkxflpcone27 +rrvoneight7fjqfj7ztqfpqpbxhmmthreefvg +seven26sevenndhx3 +8zsevenfiveeightkcsmvjfpkhmddqgqcfivemjgfnpznv +threepscjlrdgjkhr1nine +six3eightthree +1fourtwothreepdzdfxhkpx2fivesixthree +ninegtzninetwosix74 +975xglcgpjtgxthreexzjxgqcrbg +thbl93one +mzkjcgbcmj3sevenjqnhjczrsix +seven9hqxm4nine1rzd +hfneightwo3seven33 +7onefc38gdrddlzlrghfour +bf5tqthreezjkclz3qzrgdgs5 +eight9fivexpnnfktrbcfourone +three7twofive34247 +tbnsfour9jqrvsrnine +44ninekmbssnrts9ggm +vlbbrncgdtgf6 +9fivejfjxtvrtkhmfourfhkptbdmtcl +9eighttwomzdzjkponenine7two +hrsvprtwosdlsztsr3vtrhgzz1 +3six1 +9rnjtvnxlzbpctl +6xnss9qbrdcjqks +bhgvfcbnsevenvd3bdjqpkblseven8 +fourd8two +four95ppzbzfnkgd +8nine6four3rscrxpgnine7 +xhkdgkqsixmppgbffb9psix8eight +seven8xxzbhkdtdsix8sixnine +ninenineeight6sevensixsixkj +7fkthree459eightnxbqjm4 +djjfxqzbqvz4sixonesevenfiveqnbntzmgthree +pnmkclnqfbnmmninennngqplxthree1nineeightworr +zrlxlcdgd7 +eightrhzbgndlnbnrgpzvmdrfgnmheight88hgm +pr49fiveqrsix +lvvdhone638tbpmgflbf +five5htqpl +fgxznine1one1sixeightpzs5 +9twoone7cpsr +32one1five8qznp9three +16hbncsgvvxvj4 +twoeightfour6sevenqxjhlhjzsix +33ninezfrgnll8 +xrsxqzlr8 +7nine6onetwo4bbkvdmffive +sevensix54 +nztv7xhhfhdtzf8 +three8eight4fivefourfourfivecxzkqf +five2k29oneightkbp +plkkdrnvkxrnzfxkxcfourngqpgqtts476 +95eightjcgrxhflx81qqjdsnbngpfjfmcgl +6rrflzsvgbtzkncc +four5seveneight8pn +five9kzntpg34lslcvj +xhmvbsix5 +8sevenrssqkkszkhxfdgtdzkhsfht4four2 +87324eight63eight +791zdnnrprjzmkzzgtwozmtmbdlq +qdhfdnj6gdgtcqc +6vkxjnj +seveneightchz9 +3ttllxzjfmsrcxvfrdfsixthree2vnffqjdf7eight +vgrqns22eight5 +24131 +dtsix75ninefourfour +sqcnsixsfp6seven +977pmgmcdlzpzr34twothree +spxbhvssspcvvvxtgdqh3nine +eight22five6four1 +ftwoneqqj6 +56four1twotwoxcssfzbnrjtlv +seven8sixseven3kmzpgftdztgkfk +sixsix79 +vkbk9one3eightseven3three9 +five33twofpllgvxjkmdkmgnine7 +xtpfgr8hgkhxkcngthree +eightxcseven79four +16ntzfvszt1 +four33phcsqjndcjmceightrr8 +3twotwo +nfcmccvdrrnt9msgrxkfmxgtj7 +mbthree9nine +63one1nine +fivekkhkt24nn7ninethree +zrqpkk8 +gveightwo1 +sevenhlkzxhfzfxstmqkm31xq +seven4fiveeight +rr9four1 +682 +bbmz5zblhfbrkgld35fqtp +h9six24jkpvxeightnine +six17fpjzf +srdkqbtxksevenblrzrstchbp1vrvjsix9 +sixgvgjeightthree4 +cxdxqngndfmvmcpglsqfnjc6ninefourztlspndnfeight9 +gzjkvcbxl3seven23five51 +rlggvrbjbrtwo1snjgxqhvcgbonelrbcx +lkhmqnhvkncdg57fourthree +987jqjskjjxlptcvgbf +onegrlkhqhspsixnfsrvzmd6two +76five86ninenine +ninezzntx4seven983 +4pjgq +four5mmdhtnnjr3 +35flnjxqqtgtwo2 +pbsjtdneightrfjqjbjgpqfourxlzkcsrtfqnfnrvcr41 +threefourtwo2conejzkcrdrtxdrxhvlgcdtv +9onepkmeight +seventwo17seven +5ninefour +1ndchqqgpvfive7cmfrhppqpqjvhkqxlcsxxqpkf +n764eightlz +nzghqdrtn2threeeightone +7four1bbshfmtptjmkv +3fourtwodklbpbd7mbrdmf +qhcjqttwo2ninegbjqhjpjvmbndnnj2mdnzgm9 +oneseven4knpsixtwo +fivesxmsdlj8oneone +3sevenfghsxnzgkd +4four1threelhnxmldvgzmtdcrdrtmphqxfivezchzqzpdv +9849threexlxrbvp +1ninenine2fivecsbtslnjfb +7sixkrzrt3 +four7sixpspzcmzrhrgk +nhlkt5fivethree58 +sevendjsfjzhpcs7 +35vgsndjpcpfourmzzbbonejfvdtb +jqvxrhrljclhmtlfjr4nine4 +zctcbf5twosevenhzt +2six886nine2four +1vmlheightgn8cbdqfznl +sixfivexmbgfourthreeone3fourtwo +sixseven3bxdncvhpdsevensqbmzthreeseven +four5sixeight6 +9nine29gcgklf +five833three59seven +threeseven2 +bvd9129 +sdqppvccmjqbssmt75 +fouronethreenpeight22onetwo +kccninebknx7fivefivexqjnbzv4 +5nineeight92five93one +pshnzvftrfxffourthreeeighthvjs39 +seven5ttbjssdkkrsrcbdxxs325twokczrjcgt +gctwonejjxqbsbrsfnbcrsjqbcjrrlghnkktfivefive9 +6qfhdvbtp98fournineb +987six +eightseven2three6zqgqxleightwogzq +hmr7eight1eighttwo +hdktsjqcvt295hlbvrrnb6onexmkzvkz +85rlgjtbmhjcsixseventtrtxrdclthreethree +mcnlcxkgllhcdrmnl9nhpmftbcmsrbpmlhlzmq1 +37qxphtdpxhx +pgbltvonevfgfxkx2one +7oneone5six8cb +sixzfchfour5518cschjsgddcmrnmm +rkqfltmhpzgvpdmvlnscxq97fzr +735seveneightctjlsvrstr +ztqpprtg9twoeight +seven1fiveldzgspfrrnfive +dnx6 +grvzjmd43twonel +38ngdgfjszmqqh +xbtqseven3zzjghbt34sevenvslhs +threemqbjnine6tpvgsztsph8 +691seventhreeone +sqjgztldvlvgt5eightfour +ninethree9ljdjqpbbptwo +m4 +three9eighttwotwo7 +xxvqmcqjpkvtzhxv6 +eight9czs9ztq95sevenpgtfczx +3eight6four +twotwo8onesix2 +sixbxqnkleight57sixseven7 +fpdsssgnlrtwothree4 +fsbvfc6 +j1xdzttjb8kthscffsv3ptjps +2fbkckqfkfbbvzxfour +ksevenfivesixbhmknq8sjkpvvlone +zqxtwoneqkpglrfvdone8six +five521rskfhpg +seven8eight +nsztxcjeightplmcdkhbnxfclbqqq55vqxqv7 +fivevrvsnzjfzj5k279xnzmphjfql +vslc4 +czd6dngcnssxfjrqxgjksktonevrljgzbsrgg +eightdszsdrhpgnonemprjgj1nine8t +33sdtjone +three1thrd +sevensixthree5 +665fjlgq +3tzhjqhgkngqqkpmjjbqfqgonefourbhhcgxfrnine7 +nlsdv17hxkrds8dqcmrl19 +pfiveonenine8nine8 +5sevenfivepxnsdbjdsd8rpphlbz +6kmngdjzfd +8shrxvfpxzrpsjtgfour4seven13 +hjz8jcfive +8threefiveones8fivejptrmdtlrh +sspgrpbjkmbrmcbjmrhsdldone7 +scfjseight5sevenmxdrcjxjfk5dlqbxggpzfourfour +seven6nhpvxbkpxnjeighttjhxsvxcqdseven +xvnxnthq4five +five6235seven5 +hngbhb2d228 +23mfvtm1sczpzfoursevengsttvtvk +6eight82 +93sixnqkgtvnine +fivejt8 +dthgrkmvqgjlxqsixsix6r +eight51 +pdbmdccvjh3onethreetwo +cdtmdeightonesixthree43 +5twotwosevendtsngkmdrp +pgqzmr3four3one779four +qv3 +lpcklg25twoqqxjnzzgpfour +fndfr6sixseveneight8ngv +9qbnjnznrhtwomknbrknqqzfiveseven +onefivetwo5vcvkdpcone47two +three1seven58ninegsnqhjmsix +five1four8xvdsglztwoqvz +ninefourone3bzkzrsgkvh9 +7eight3pktfivenine +fivefour2four +onefive52sttrssbfour +dqthreefldqxhbbf6vrzgvcmjbsix2qfmjdhk +9seveneightltwo59rnqh +13twotwonec +twoeightfive4krnsmqdqmxblnlmdone +seven28foureightonedvplrrz8nine +eight3hsjcntf2zjkdnxkd +fb42bkgxbxmjg1 +7mdp9 +cntwo15 +51jzqjvfbqq +bnzmrjhvgsixeightql5xvj +5four6987two +4rnhhlq86dl87peightwogv +8threenine +9rbfcrcqjmvpqrjjntjmtsrgsonethreezhggkc +6xstwozrxoneeight +onehvxsxzs5 +222 +4ldl518gqkmghkkgqthreepnjj1 +nine1qmxv +ninetmcjmzjrfive6eightthree +5ssm6six9threemkmsxrgbkjmhhk +threeeightjgjrgq45 +15jvkvbckg82chx +4jlkszzrk +51phvpfdtmncdseven8xzgfzqznzmfour +two15sevensevensevenngfvkktzpq +nflkhvjddnine15ssbmn +vspsrcnm5three9seven +cktcm9 +3qbtxxt9threefjkbnsvk +one1three +fournjdvtchpkdfivel5lznine +one9sixthreethreeonefive +oneeightfourfzntntfivehnfvrrprgptkxs2 +sixclpnhlbsqm4 +seven5oneeightfoureight +7twofivemhhqn32sevenfddmcpbzpngclszh +869ksktveightthree +eighttwo6472four1six +5fivelkmcmgvvkxonelclmvjnphvc5b +brrzlhpbpfivefourrfmbtjrdltsgm8fivethree +four79 +six28four3 +2bsgzdjlllxfournsixrtbpvkm4 +gbdqj342cqx +69ztzmzsfive48gtxqnjsvqr6 +3seven8mdbsevennine +sixx1five +2bbjt +tfs9msevenv61 +8four25onegpbrhsmvx7threeone +8sevenhmddktxbxvdnqtlrbseven +5onethree3 +rhlrbskeightzdfprx1 +threebvjcbssmvk2rpszhvvpzlrmcthree +5hffqfn2 +tbgjrhjshhkcl4kdznkqzonefour +seven6seveneightthree85 +six1threebvflqkctflthree +eightxpvxvn2cv +945threenineqjfive +nc7 +9onekptdkglrnloneightfr +5three6sevenhzxtfnkrv2 +813seventhree +8sqmnkqrq4kbsix +five17flrtthzttdhdcnbbzdhhfourtgpbheight +nncrjqcsmjlsix2threeeightjlgznzlqg1 +three1six9two +9twofqnnhfkkqbdskzpgvp +65mcknzkjnine55seven74 +pkd4ptgznrjdk +sqjsp1rdxj +1rs2 +zzsxzczsxpkrsnnm869 +fiverxjfqdspmglfldbbfsrqfx487 +tfive7krmfjptnrcjxfmpfzz6frtknvcvfive +85seventwoone9 +rmfivetkjmsvt6 +ntwonexninednftfzjxxjzpz5eightzvhkqf3 +3799sixsixeight35 +zltzhvnr5ksthree5 +cpbeightr5three +four24sixzbxggddfcr7nine +5oneonevdzjmfcchxoneeightp81 +four8ljlssqjffninefournffnzgcjczpj1 +6tvbdrk4 +rxsbbq59 +13four4zvkztttjcrfourgv +9hntfbsevencqzsbbxkdgxfxztwo +two99one3518six +lzxpgtzflhkdf5 +vmmdpzfourcxcctv9jjzrhttjmg2bvhhqxxsmz4 +6kr9cbdflmngqt6 +ninetldzdnqvrninerphskmntfrpg2 +2nine3hr91threevpbf +8three8eight +tcqfivelklqtqtwofive7 +qnzrtbzcb2sixeightxrzsseventwofour +t5one4two1tbsqkfour +seven7threesevenonekcmzv +3812 +twotwoonethreethree8 +34292 +3eightnldtmmmmknkzs2fiveg +five144four1fourdzlpvxttvbxb +hmkz5sevennine +one77ninetwoseventhreedqljsvj5oneightv +rnnkdtfgtctqeight53sevenseventwo +qxfkvfbktgp34fthtsvhone +1vxkbzhssixeight8ljmhrztjbnineeight +5fourm1 +eightxk4vkmqqkfxonetwolqngzj6one +3five2 +sevendnrkfhjdpz43one52eightnhljq +812781rbl68 +nine9two7xkjdlrrpgxbcfmpfmzsevenkkzxnxbfour +lsgxrbpgnh7 +pmnkgrgnznsvjxcfn3816six6 +1sevengfncznxvsckxnmnmsckgs +jbmmvjgkt28 +fgpqzqvfsxddlk7csixeight +64six6vfgxthree5mdjsn3 +cbjpqhnrfivefourfxxbctjkhkonebpqlzbdn73 +5rxdqseventhreefivesghndzjtksnxd +3tworxcbnqlhv +eightsix67 +5pfzht +fourkv4 +five1four4sixtwo +four1svhqsgznb6spknchrhftchpk +ninetwo8seventhree +9threenbnzclccnmfrv +3vhlnrbbdhkone +98three4jksqb3hpgseven +four1lpspjrqtmxonefive5four8 +qnnfzgbgsixthree2 +752seven +1msxrzzzxnninefour6 +onetwooneonef33 +fourcdone253eightthree +1eighteightqqpd +5four54fourjvsf +kgkggx9fivesixfdpcmdddskrtdqjmmcfivevkjspb +sevenjll3cdktmvdk +7two6sixkmrmxrhlqtmffbgr9 +8kqzkcb +grsksnfr6sixfourpeight +7sevensixsixsvseven8qtdppfg +lgqb3tleight +98lsseven +sfbzrtjfivefoursm4 +eighteightthreelncqspmzd5gmpdtrsjkjzlklt +oneoneseven2n +qqzfvbfourone9 +onebhtglzjsmhncmkfln1xj7 +phonenjjmdzkbzftworjvcvn1eightwox +twoeightfcrnmvvbrd93threetkhklbcxdptfq +four7five9nd31 +three1frglrrm435dsqbxxtrj7 +twothree78fpghbvq7jfsjsqnd +hvmbmqnxk4onesix29kdhrdqtcfx1znmjhfjx +3twoeighteightfivepztpjsbcrfour +16stctmrmj3threeninepdsxb +seven7nhrtgnltntgfzb +one1onermlsevenseven +17fkg +53ldplzx diff --git a/2023/day01/main.go b/2023/day01/main.go new file mode 100644 index 0000000..dea8615 --- /dev/null +++ b/2023/day01/main.go @@ -0,0 +1,97 @@ +package main + +import ( + "fmt" + + h "git.bullercodeworks.com/brian/adventofcode/helpers" +) + +func main() { + inp := h.StdinToStringSlice() + part1(inp) + part2(inp) +} + +func part1(input []string) { + var value int + for _, i := range input { + value = value + getValue(i, false) + } + fmt.Println("# Part 1") + fmt.Println(value) +} + +var nums = []string{ + "zero", + "one", + "two", + "three", + "four", + "five", + "six", + "seven", + "eight", + "nine", +} + +func part2(input []string) { + var value int + for _, i := range input { + value = value + getValue(i, true) + } + fmt.Println("# Part 2") + fmt.Println(value) +} + +func getValue(wrk string, p2 bool) int { + return (getFirstValue(wrk, p2) * 10) + getLastValue(wrk, p2) +} +func getFirstValue(wrk string, p2 bool) int { + for j := 0; j < len(wrk); j++ { + if p2 { + v := numStringAt(wrk, j) + if v > -1 { + return v + } + } + if wrk[j]-'0' >= 0 && wrk[j]-'0' <= 9 { + return int(wrk[j] - '0') + } + } + return 0 +} +func getLastValue(wrk string, p2 bool) int { + for j := len(wrk) - 1; j >= 0; j-- { + if p2 { + v := numStringAt(wrk, j) + if v > -1 { + return v + } + } + if wrk[j]-'0' >= 0 && wrk[j]-'0' <= 9 { + return int(wrk[j] - '0') + } + } + return 0 +} + +func numStringAt(haystack string, pos int) int { + for i := range nums { + if stringAt(haystack, pos, nums[i]) { + return i + } + } + return -1 +} + +func stringAt(haystack string, pos int, needle string) bool { + if len(haystack) < pos+len(needle) { + return false + } + for i := range needle { + if haystack[pos+i] != needle[i] { + return false + } + } + return true +} diff --git a/2023/day01/problem b/2023/day01/problem new file mode 100644 index 0000000..772507d --- /dev/null +++ b/2023/day01/problem @@ -0,0 +1,86 @@ +Advent of Code + +br0xen (AoC++) 2* + +--- 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? + + Your puzzle answer was 55029. + +--- 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? + + Your puzzle answer was 55686. + + Both parts of this puzzle are complete! They provide two gold stars: ** + + At this point, you should return to your Advent calendar and try another puzzle. + + If you still want to see it, you can get your puzzle input. + +References + + Visible links + . https://adventofcode.com/ + . https://adventofcode.com/2023/about + . https://adventofcode.com/2023/events + . https://teespring.com/stores/advent-of-code + . https://adventofcode.com/2023/settings + . https://adventofcode.com/2023/auth/logout + . Advent of Code Supporter + https://adventofcode.com/2023/support + . https://adventofcode.com/2023 + . https://adventofcode.com/2023 + . https://adventofcode.com/2023/support + . https://adventofcode.com/2023/sponsors + . https://adventofcode.com/2023/leaderboard + . https://adventofcode.com/2023/stats + . https://adventofcode.com/2023/sponsors + . https://adventofcode.com/2015/day/1 + . https://en.wikipedia.org/wiki/Trebuchet + . https://adventofcode.com/2023 + . https://adventofcode.com/2023/day/1/input diff --git a/2023/day01/testinput b/2023/day01/testinput new file mode 100644 index 0000000..7bbc69a --- /dev/null +++ b/2023/day01/testinput @@ -0,0 +1,4 @@ +1abc2 +pqr3stu8vwx +a1b2c3d4e5f +treb7uchet diff --git a/2023/day01/testinput2 b/2023/day01/testinput2 new file mode 100644 index 0000000..41aa89c --- /dev/null +++ b/2023/day01/testinput2 @@ -0,0 +1,7 @@ +two1nine +eightwothree +abcone2threexyz +xtwone3four +4nineeightseven2 +zoneight234 +7pqrstsixteen