From 6c6b50dee0515dfd7baae6c1a05fbb5c9320b4ff Mon Sep 17 00:00:00 2001 From: Fabian Schmidt Date: Mon, 28 Oct 2024 13:29:30 +0100 Subject: [PATCH] y2015d5 --- y2015/resources/5_input.txt | 1000 +++++++++++++++++++++++++++++++++++ y2015/src/bin/d5.rs | 20 + y2015/src/days/d5.rs | 105 ++++ y2015/src/days/mod.rs | 1 + 4 files changed, 1126 insertions(+) create mode 100644 y2015/resources/5_input.txt create mode 100644 y2015/src/bin/d5.rs create mode 100644 y2015/src/days/d5.rs diff --git a/y2015/resources/5_input.txt b/y2015/resources/5_input.txt new file mode 100644 index 0000000..7bc179c --- /dev/null +++ b/y2015/resources/5_input.txt @@ -0,0 +1,1000 @@ +uxcplgxnkwbdwhrp +suerykeptdsutidb +dmrtgdkaimrrwmej +ztxhjwllrckhakut +gdnzurjbbwmgayrg +gjdzbtrcxwprtery +fbuqqaatackrvemm +pcjhsshoveaodyko +lrpprussbesniilv +mmsebhtqqjiqrusd +vumllmrrdjgktmnb +ptsqjcfbmgwdywgi +mmppavyjgcfebgpl +zexyxksqrqyonhui +npulalteaztqqnrl +mscqpccetkktaknl +ydssjjlfejdxrztr +jdygsbqimbxljuue +ortsthjkmlonvgci +jfjhsbxeorhgmstc +vdrqdpojfuubjbbg +xxxddetvrlpzsfpq +zpjxvrmaorjpwegy +laxrlkntrukjcswz +pbqoungonelthcke +niexeyzvrtrlgfzw +zuetendekblknqng +lyazavyoweyuvfye +tegbldtkagfwlerf +xckozymymezzarpy +ehydpjavmncegzfn +jlnespnckgwmkkry +bfyetscttekoodio +bnokwopzvsozsbmj +qpqjhzdbuhrxsipy +vveroinquypehnnk +ykjtxscefztrmnen +vxlbxagsmsuuchod +punnnfyyufkpqilx +zibnnszmrmtissww +cxoaaphylmlyljjz +zpcmkcftuuesvsqw +wcqeqynmbbarahtz +kspontxsclmbkequ +jeomqzucrjxtypwl +ixynwoxupzybroij +ionndmdwpofvjnnq +tycxecjvaxyovrvu +uxdapggxzmbwrity +csskdqivjcdsnhpe +otflgdbzevmzkxzx +verykrivwbrmocta +ccbdeemfnmtputjw +suyuuthfhlysdmhr +aigzoaozaginuxcm +ycxfnrjnrcubbmzs +fgbqhrypnrpiizyy +taoxrnwdhsehywze +echfzdbnphlwjlew +jhmomnrbfaawicda +fywndkvhbzxxaihx +aftuyacfkdzzzpem +yytzxsvwztlcljvb +iblbjiotoabgnvld +kvpwzvwrsmvtdxcx +ardgckwkftcefunk +oqtivsqhcgrcmbbd +wkaieqxdoajyvaso +rkemicdsrtxsydvl +sobljmgiahyqbirc +pbhvtrxajxisuivj +ggqywcbfckburdrr +gmegczjawxtsywwq +kgjhlwyonwhojyvq +bpqlmxtarjthtjpn +pxfnnuyacdxyfclr +isdbibbtrqdfuopn +vucsgcviofwtdjcg +ywehopujowckggkg +mzogxlhldvxytsgl +mllyabngqmzfcubp +uwvmejelibobdbug +brebtoppnwawcmxa +fcftkhghbnznafie +sqiizvgijmddvxxz +qzvvjaonnxszeuar +abekxzbqttczywvy +bkldqqioyhrgzgjs +lilslxsibyunueff +ktxxltqgfrnscxnx +iwdqtlipxoubonrg +twncehkxkhouoctj +bdwlmbahtqtkduxz +smbzkuoikcyiulxq +bjmsdkqcmnidxjsr +icbrswapzdlzdanh +eyszxnhbjziiplgn +pdxhrkcbhzqditwb +nfulnpvtzimbzsze +glayzfymwffmlwhk +bejxesxdnwdlpeup +ukssntwuqvhmsgwj +hoccqxlxuuoomwyc +rapztrdfxrosxcig +cxowzhgmzerttdfq +yzhcurqhdxhmolak +kqgulndpxbwxesxi +yjkgcvtytkitvxiu +xnhfqhnnaceaqyue +qkuqreghngfndifr +xesxgeaucmhswnex +occbvembjeuthryi +dmefxmxqjncirdwj +ystmvxklmcdlsvin +pplykqlxmkdrmydq +cbbjkpbdvjhkxnuc +embhffzsciklnxrz +asrsxtvsdnuhcnco +xcbcrtcnzqedktpi +mglwujflcnixbkvn +mnurwhkzynhahbjp +cekjbablkjehixtj +kbkcmjhhipcjcwru +usifwcsfknoviasj +rsfgocseyeflqhku +prgcyqrickecxlhm +asbawplieizkavmq +sylnsirtrxgrcono +nzspjfovbtfkloya +qfxmsprfytvaxgtr +yckpentqodgzngnv +ycsfscegcexcnbwq +kbmltycafudieyuh +tpahmvkftilypxuf +qivqozjrmguypuxu +gdhbfradjuidunbk +vxqevjncsqqnhmkl +rpricegggcfeihst +xucvzpprwtdpzifq +egyjcyyrrdnyhxoo +kfbrzmbtrrwyeofp +qpjdsocrtwzpjdkd +reboldkprsgmmbit +vwkrzqvvhqkensuy +ydvmssepskzzvfdp +vqbigplejygdijuu +mzpgnahrhxgjriqm +uiejixjadpfsxqcv +tosatnvnfjkqiaha +yipuojpxfqnltclx +pcxwvgcghfpptjlf +shrudjvvapohziaj +jdckfjdtjsszdzhj +hgisfhcbdgvxuilk +gytnfjmrfujnmnpp +ohflkgffnxmpwrrs +jzxajbkwwjknasjh +xrcxfollmejrislv +djjlwykouhyfukob +rittommltkbtsequ +lpbvkxdcnlikwcxm +vkcrjmcifhwgfpdj +dkhjqwtggdrmcslq +swnohthfvjvoasvt +yrzoksmcnsagatii +duommjnueqmdxftp +inlvzlppdlgfmvmx +xibilzssabuqihtq +inkmwnvrkootrged +ldfianvyugqtemax +gbvwtiexcuvtngti +temjkvgnwxrhdidc +askbbywyyykerghp +onezejkuwmrqdkfr +kybekxtgartuurbq +ubzjotlasrewbbkl +stueymlsovqgmwkh +lhduseycrewwponi +yohdmucunrgemqcu +onnfbxcuhbuifbyc +odrjkigbrsojlqbt +imqkqqlkgmttpxtx +sxmlkspqoluidnxw +akaauujpxhnccleb +xvgpghhdtpgvefnk +jdxeqxzsbqtvgvcq +mdusenpygmerxnni +agihtqvgkmgcbtaw +dovxcywlyvspixad +uulgazeyvgtxqkfz +ndhmvrwuflhktzyo +hcaqkmrbvozaanvm +tvfozbqavqxdqwqv +rlkpycdzopitfbsv +dmyjtmjbtnvnedhs +fmwmqeigbzrxjvdu +twgookcelrjmczqi +grxosmxvzgymjdtz +zsstljhzugqybueo +jpeapxlytnycekbd +iasykpefrwxrlvxl +azohkkqybcnsddus +aoaekngakjsgsonx +awsqaoswqejanotc +sgdxmketnjmjxxcp +ylnyuloaukdrhwuy +ewoqjmakifbefdib +ytjfubnexoxuevbp +ewlreawvddptezdd +vmkonztwnfgssdog +ahbpuqygcwmudyxn +kmahpxfjximorkrh +otjbexwssgpnpccn +aewskyipyztvskkl +urqmlaiqyfqpizje +nrfrbedthzymfgfa +vndwwrjrwzoltfgi +iiewevdzbortcwwe +qiblninjkrkhzxgi +xmvaxqruyzesifuu +yewuzizdaucycsko +hmasezegrhycbucy +dwpjrmkhsmnecill +hnffpbodtxprlhss +avmrgrwahpsvzuhm +nksvvaswujiukzxk +zzzapwhtffilxphu +vwegwyjkbzsrtnol +qurpszehmkfqwaok +iknoqtovqowthpno +brlmpjviuiagymek +efxebhputzeulthq +mzkquarxlhlvvost +xsigcagzqbhwwgps +qufztljyzjxgahdp +dlfkavnhobssfxvx +hgdpcgqxjegnhjlr +fboomzcvvqudjfbi +wnjuuiivaxynqhrd +nhcgzmpujgwisguw +wjeiacxuymuhykgk +qmeebvxijcgdlzpf +nmmnxsehhgsgoich +ejluaraxythbqfkl +mdbsbwnaypvlatcj +nnfshfibmvfqrbka +dvckdmihzamgqpxr +foztgqrjbwyxvewk +okpryqcbvorcxhoh +fpiwsndulvtthctx +zrbiovlmzdmibsiq +setwafbnnzcftutg +nyvqghxhgkxfobdm +enpvqadzarauhajl +twblhpvkazpdmhmr +lbhlllsgswvhdesh +tdfwkgxnqjxcvsuo +lnvyjjbwycjbvrrb +jsxqdvmzaydbwekg +xirbcbvwlcptuvoa +hwnukxenilatlfsk +khwopjqkxprgopmd +sljzdoviweameskw +stkrdmxmpaijximn +fdilorryzhmeqwkc +mfchaaialgvoozra +gjxhoxeqgkbknmze +beowovcoqnginrno +mkgmsgwkwhizunxo +phnhfusyoylvjdou +csehdlcmwepcpzmq +pgojomirzntgzohj +fkffgyfsvwqhmboz +mrvduasiytbzfwdn +epzrmsifpmfaewng +ooqxnoyqrlozbbyf +ahcxfmgtedywrbnx +ibqktvqmgnirqjot +xarssauvofdiaefn +xradvurskwbfzrnw +nxklmulddqcmewad +twichytatzoggchg +qmgvroqwrjgcycyv +yvezgulgrtgvyjjm +jgmcklzjdmznmuqk +bytajdwwconasjzt +apjttucpycyghqhu +flfejjzihodwtyup +gmrtrwyewucyqotv +nlohdrlymbkoenyl +wxcmqwbrwgtmkyfe +njtzlceyevmisxfn +htbbidsfbbshmzlt +gxhjeypjwghnrbsf +cifcwnbtazronikv +ezvjijcjcyszwdjy +srffeyrvyetbecmc +xpjefrtatrlkbkzl +yhncvfqjcyhsxhbb +pqhcufzlcezhihpr +qtdsfvxfqmsnzisp +dfonzdicxxhzxkrx +mqqqzhxkyfpofzty +dodjadoqyxsuazxt +jjwkrlquazzjbvlm +ttosfloajukoytfb +llateudmzxrzbqph +criqihrysgesmpsx +npszvlittbcxxknj +qmzojrvraitrktil +cfyoozzpwxwkwoto +daxohtcgvtktggfw +vthkpkoxmiuotjaj +pkfkyobvzjeecnui +ojcjiqrfltbhcdze +scbivhpvjkjbauun +ysowvwtzmqpjfwyp +laeplxlunwkfeaou +jufhcikovykwjhsa +xrucychehzksoitr +pyaulaltjkktlfkq +oypfrblfdhwvqxcv +zybrgxixvhchgzcf +puoagefcmlxelvlp +xjnhfdrsbhszfsso +ocgvzryoydaoracw +bxpnqllmptkpeena +pziyeihxlxbbgdio +bvtrhtlbfzmglsfc +ggpuvtseebylsrfk +pukenexjqecnivfj +jswabfbzpnhhdbpn +enojrtwqpfziyqsv +rjtmxudgcudefuiz +iqmjxynvtvdacffc +uheywxlsusklitvl +kwhxduejafdpmqdc +rspgblenbqlmcltn +rczhurnrqqgjutox +dqhytibjzxkdblzl +hpbieadydiycvfys +pucztfoqvenxiuym +nqpfzgpblwijiprf +ltgseeblgajbvltk +mwxukbsnapewhfrc +dvxluiflicdtnxix +pexfbpgnqiqymxcq +dakudfjjwtpxuzxy +letlceyzlgmnrewu +ojktahbsdifdfhmd +anezoybbghjudbih +sawxtlvzysaqkbbf +ttnkctcevpjiwqua +edrwrdvbaoqraejd +wnbfilvuienjxlcr +wqhzwvyybyxhhtsm +jxbgvyaqczwdlxfo +wbypqfmbwrsvfmdv +izdxjyfpidehbets +vbxbggqseurknjor +egpmpoxickhvwdlz +ivfrzklvpwoemxsy +xkziseheibmrpdww +xnrmtoihaudozksa +efemdmbxdsaymlrw +yjdjeckmsrckaagx +vlftqxxcburxnohv +fwyquwgajaxebduj +dwpmqvcxqwwnfkkr +isduxxjfsluuvwga +avdtdppodpntojgf +vrcoekdnutbnlgqk +kbhboxjmgomizxkl +cgsfpjrmewexgzfy +usdtnhjxbvtnafvp +bjoddgxbuxzhnsqd +hoyqdzofddedevsb +rwiwbvqfjajotaoj +iabomphsuyfptoos +bubeonwbukprpvhy +xurgunofmluhisxm +puyojzdvhktawkua +dbvqhztzdsncrxkb +oaeclqzyshuuryvm +nmgwfssnflxvcupr +vjkiwbpunkahtsrw +romyflhrarxchmyo +yecssfmetezchwjc +qwtocacqdslhozkd +mesexvfbtypblmam +mtjucgtjesjppdtt +pvodhqqoeecjsvwi +vvlcwignechiqvxj +wiqmzmmjgjajwgov +kwneobiiaixhclev +lkdeglzrrxuomsyt +oqovuwcpwbghurva +lfsdcxsasmuarwwg +awkbafhswnfbhvck +sztxlnmyvqsiwljg +hozxgyxbcxjzedvs +oifkqgfqmflxvyzn +mfvnehsajlofepib +delgbyfhsyhmyrfa +uenimmwriihxoydv +vjqutpilsztquutn +kfebsaixycrodhvl +coifyqfwzlovrpaj +xiyvdxtkqhcqfsqr +hoidcbzsauirpkyt +fiumhfaazfkbaglq +fzwdormfbtkdjgfm +faxqrortjdeihjfv +ljhaszjklhkjvrfi +pzrxsffkuockoqyl +immbtokjmwyrktzn +lzgjhyiywwnuxpfx +vhkocmwzkfwjuzog +ghntjkszahmdzfbl +gbcthxesvqbmzggy +oyttamhpquflojkh +nbscpfjwzylkfbtv +wnumxzqbltvxtbzs +jfhobjxionolnouc +nrtxxmvqjhasigvm +hweodfomsnlgaxnj +lfgehftptlfyvvaj +ccoueqkocrdgwlvy +euhgvirhsaotuhgf +pdlsanvgitjvedhd +seokvlbhrfhswanv +pntdqaturewqczti +jkktayepxcifyurj +dhzzbiaisozqhown +wehtwakcmqwczpbu +zwvozvspqmuckkcd +efucjlrwxuhmjubr +lzodaxuyntrnxwvp +qdezfvpyowfpmtwd +mizijorwrkanesva +txmitbiqoiryxhpz +xhsqgobpouwnlvps +muixgprsknlqaele +disgutskxwplodra +bmztllsugzsqefrm +ymwznyowpaaefkhm +ebfifzloswvoagqh +pkldomvvklefcicw +ziqzbbfunmcgrbtq +iuekfpbkraiwqkic +jflgjidirjapcuqo +achsfbroyrnqnecg +udbhouhlgjjzapzr +arerrohyhhkmwhyo +txyjzkqexgvzdtow +ogzrjwibvzoucrpg +rfdftaesxdnghwhd +axdhwmpuxelmpabo +gtktemowbsvognac +wkfuclilhqjzxztk +qbwjouutzegaxhrz +opfziwqqbwhzzqhj +pvcvcsupfwsmeacs +xsbohvbguzsgpawn +sczoefukwywxriwj +oqkhcqfdeaifbqoc +vtsrholxbjkhwoln +yuvapljnwbssfbhi +dxdfwccqvyzeszyl +gdbmjtonbiugitmb +qunirtqbubxalmxr +zzxsirhdaippnopr +fibtndkqjfechbmq +gqgqyjvqmfiwiyio +ihwsfkwhtzuydlzw +eygyuffeyrbbhlit +zdlsaweqomzrhdyy +ptbgfzuvxiuuxyds +llxlfdquvovzuqva +wfrltggyztqtyljv +kwipfevnbralidbm +gbhqfbrvuseellbx +obkbuualrzrakknv +hlradjrwyjgfqugu +vtqlxbyiaiorzdsp +tedcbqoxsmbfjeyy +cxdppfvklbdayghy +gjnofexywmdtgeft +ldzeimbbjmgpgeax +egrwsmshbvbawvja +vadfrjvcrdlonrkg +mojorplakzfmzvtp +jyurlsoxhubferpo +ijwqogivvzpbegkm +cnmetoionfxlutzg +lawigelyhegqtyil +mqosapvnduocctcd +eqncubmywvxgpfld +vigfretuzppxkrfy +ncwynsziydoflllq +cbllqinsipfknabg +ndtbvdivzlnafziq +iqrrzgzntjquzlrs +damkuheynobqvusp +jxctymifsqilyoxa +ylritbpusymysmrf +paoqcuihyooaghfu +obhpkdaibwixeepl +igrmhawvctyfjfhd +ybekishyztlahopt +vkbniafnlfqhhsrq +kltdigxmbhazrywf +ufhcoyvvxqzeixpr +klcxdcoglwmeynjt +funpjuvfbzcgdhgs +akgyvyfzcpmepiuc +zhlkgvhmjhwrfmua +ibsowtbnrsnxexuz +vpufbqilksypwlrn +ngrintxhusvdkfib +ziuwswlbrxcxqslw +sucledgxruugrnic +zwnsfsyotmlpinew +oaekskxfcwwuzkor +qjmqwaktpzhwfldu +tmgfgqgpxaryktxo +qfaizepgauqxvffk +addkqofusrstpamf +shdnwnnderkemcts +gwfygbsugzptvena +fpziernelahopdsj +bkkrqbsjvyjtqfax +gxrljlqwxghbgjox +ipfwnqaskupkmevm +nnyoyhnqyfydqpno +lgzltbrrzeqqtydq +fgzxqurhtdfucheb +jvpthtudlsoivdwj +bmlhymalgvehvxys +fhklibetnvghlgnp +hfcyhptxzvblvlst +donanindroexgrha +oqawfmslbgjqimzx +jzgehjfjukizosep +bhlgamcjqijpvipb +jrcrdjrvsyxzidsk +ouwfwwjqezkofqck +wrvsbnkhyzayialf +knhivfqjxrxnafdl +hbxbgqsqwzijlngf +qlffukpfmnxpfiyq +evhxlouocemdkwgk +baxhdrmhaukpmatw +nwlyytsvreqaminp +ljsjjzmlsilvxgal +onunatwxfzwlmgpk +njgolfwndqnwdqde +ngdgcjzxupkzzbqi +ieawycvvmvftbikq +ccyvnexuvczvtrit +enndfwjpwjyasjvv +tcihprzwzftaioqu +bkztdkbrxfvfeddu +qkvhtltdrmryzdco +rurtxgibkeaibofs +mjxypgscrqiglzbp +unpkojewduprmymd +csqtkhjxpbzbnqog +mednhjgbwzlhmufi +sfrwfazygygzirwd +ijqeupbrhhpqxota +cmhpncanwudyysyh +wwcxbwzrplfzrwxd +jriomldifuobjpmq +radonyagpulnnyee +ryqjwxsspbbhnptd +yeoqpnsdhludlmzf +qsqlkeetyalenueh +qnnedenwsjdrcrzt +lejkuhsllxbhfcrx +anddbvllrrqefvke +wdtljquijaksvdsv +adslgvfuqqdkzvbc +whbccefjpcnjwhaq +kqrfuankaibohqsg +fyxisfwihvylgnfd +rwqdrddghyqudcif +syhzowthaaiiouaf +zjmrtgrnohxmtidu +deecwkfvjffxrzge +dztmvolqxkhdscxe +cdghcrgavygojhqn +pepqmdbjhnbugqeu +pnumdjpnddbxhieg +jzfhxeyahiagizfw +hdkwugrhcniueyor +gmgudeqlbmqynflu +toidiotdmfkxbzvm +pyymuoevoezlfkjb +etrbwuafvteqynlr +usvytbytsecnmqtd +dfmlizboawrhmvim +vrbtuxvzzefedlvs +vslcwudvasvxbnje +xdxyvoxaubtwjoif +mduhzhascirittdf +cqoqdhdxgvvvxamk +dshnfwhqjbhuznqr +zimthfxbdmkulkjg +luylgfmmwbptyzpj +iujpcgogshhotqrc +caqcyzqcumfljvsp +sprtitjlbfpygxya +fnconnrtnigkpykt +irmqaqzjexdtnaph +bbqrtoblmltvwome +ozjkzjfgnkhafbye +hwljjxpxziqbojlw +zahvyqyoqnqjlieb +dptshrgpbgusyqsc +uzlbnrwetkbkjnlm +yccaifzmvbvwxlcc +wilnbebdshcrrnuu +evxnoebteifbffuq +khbajekbyldddzfo +kjivdcafcyvnkojr +wtskbixasmakxxnv +uzmivodqzqupqkwx +rxexcbwhiywwwwnu +rowcapqaxjzcxwqi +fkeytjyipaxwcbqn +pyfbntonlrunkgvq +qiijveatlnplaifi +ltnhlialynlafknw +urrhfpxmpjwotvdn +xklumhfyehnqssys +civrvydypynjdoap +fvbmxnfogscbbnyd +oznavyflpzzucuvg +iyshrpypfbirahqo +qmzbfgelvpxvqecy +xkkxaufomsjbofmk +irlouftdmpitwvlq +csjoptbdorqxhnjg +bkryeshfsaqpdztm +guxbdqzfafsjoadl +tgrltexgrzatzwxf +cwsgsijqdanubxad +xafnexgturwrzyrg +apcrsqdbsbaxocxr +pspgxnzcevmvvejk +szephmeegvegugdt +ndjsoloeacasxjap +bdnfksliscnirjfu +ehglacmzpcgglpux +jwweijomqfcupvzw +yesblmmkqhbazmdu +sjsmalypmuslzgac +fkiqatyttlnuhdho +tlhnyuzdocvfdihq +ngehtjmycevnybga +obxodzcdgtrycgry +stkyrvdfbwovawmk +bdkhqcfrqaxhxloo +gpvumnuoiozipnrk +jbhanddinpqhxeol +hwkzkmbmsrvunzit +rfuomegkxbyamjpw +yzbljuksletipzwm +eafedkagwitzqigl +prenqvsbotqckgwy +spedpbwzphdrfxfz +cmsuqwemhwixkxet +xgdyeqbqfldvaccq +eooxgsrfsbdaolja +kyhqylxooewrhkho +mswieugqpoefmspt +uszoqundysdyeqlc +hkmjdggxefdyykbq +dtuhjnlaliodtlvh +oalbueqbhpxoxvvx +oowxtxsoqdwhzbya +lclajfsrpmtwvzkm +fxmjufpqtpyazeqo +ozlmreegxhfwwwmf +mqzrajxtxbaemrho +nfglecsyqduhakjr +nkxqtmasjjkpkqbp +jjfonbqimybvzeus +vjqkhkhjlmvpwkud +wxxhnvfhetsamzjr +pladhajujzttgmsw +dbycgxeymodsdlhm +qxszeuaahuoxjvwu +adultomodzrljxve +dmhgrbhvvpxyzwdn +slohrlwxerpahtyp +mngbocwyqrsrrxdb +facyrtflgowfvfui +hyvazpjucgghmmxh +twtrvjtncmewcxit +uejkrpvilgccfpfr +psqvolfagjfvqkum +nvzolslmiyavugpp +lpjfutvtwbddtqiu +fkjnfcdorlugmcha +eaplrvdckbcqqvhq +xrcydhkockycburw +iswmarpwcazimqxn +kicnnkjdppitjwrl +vwywaekzxtmeqrsu +dxlgesstmqaxtjta +pmeljgpkykcbujbb +vhpknqzhgnkyeosz +jprqitpjbxkqqzmz +fiprxgsqdfymyzdl +dzvfwvhfjqqsifga +aeakhfalplltmgui +frqrchzvenhozzsu +hsvikeyewfhsdbmy +puedjjhvxayiwgvg +zmsonnclfovjoewb +bnirelcaetdyaumi +szvudroxhcitatvf +sccfweuyadvrjpys +yiouqrnjzsdwyhwa +xyjhkqbnfmjjdefz +fjwgemkfvettucvg +aapqpwapzyjnusnr +dytxpkvgmapdamtc +hgocpfoxlheqpumw +twzuiewwxwadkegg +qdbosnhyqmyollqy +fclbrlkowkzzitod +sgxnrrpwhtkjdjth +xckvsnkvnvupmirv +nioicfeudrjzgoas +lcemtyohztpurwtf +oyjxhhbswvzekiqn +idkblbyjrohxybob +rthvloudwmktwlwh +oyzhmirzrnoytaty +ysdfhuyenpktwtks +wxfisawdtbpsmwli +vgmypwlezbmzeduk +rpepcfpelvhzzxzj +zxbovsmixfvmamnj +cpkabmaahbnlrhiz +jvomcbqeoqrmynjj +iqdeisnegnkrkdws +ilhemlrtxdsdnirr +fjimtscrwbfuwmpo +lmfiylebtzwtztmx +ddouhysvomrkcpgu +xtjwvzdhgnwwauwi +cntzuwcumbsebwyy +hieqvdlvnxkygeda +hushfszxskjdrjxi +xvdfzqblccfoxvyq +nldnrtieteunyxnb +vszpidfocenlhzqb +ofcuvtwhortxesoq +bwniqemqwxlejcfq +wkqiwdjnytjnomps +rbadoommlmrictte +nsmxhpothlulxivt +bvzbfcvenskqxejr +sdqeczmzpqqtqabq +bjveyzniaaliatkw +zxsqlntyjajjxytk +jkoxlerbtidsuepg +ewtlibdkeqwgxnqt +lmrshemwxrdwzrgc +nekcdyxmftlymfir +edaqvmulzkskzsfy +znmvqaupykjmyebx +ximtebuxwhqpzubd +rrlstppkknqyxlho +uyibwcitxixjfwcr +chrvoierkimesqmm +dltxmwhheldvxwqe +xfuthxjuuizanfjy +vtiwavmxwonpkpug +phchnujfnxewglht +owvmetdjcynohxtw +cbtujdrumixxatry +iirzildsfxipfipe +sqxcscqyofohotcy +sbubnekndkvovuqg +jzhsqqxqdrtibtcd +mscwasyvxkhlvwbn +bpafxtagbuxivbwz +uhvueesygaxrqffw +trrxlibhtmzuwkkl +yktkmkokmfslgkml +gfzzzdptaktytnqg +pgqmaiwzhplnbyhg +qjiptlkwfshunsfb +lewvlpescsyunxck +tywsfatykshogjas +qtrnwjjgxdektjgi +arypcritpwijczkn +jwxvngigbhfpiubf +upsjdctitlbqlnhf +lvpjlrpnmdjiscrq +jvzchdrsnkgpgsti +wuoesbwunpseyqzu +xuqspvoshgxmrnrb +icdawnmfnpnmyzof +hwcwtibgpvctznuo +bzdjrniddyamfloq +hffkxtzuazageruv +deixfxjvzbitalnc +zihsohukiqrgsnvw +nwoondfnlgowavkg +qnuulsywgnoillgn +koozejhfjyzuhviy +oetcoipohymhpump +cizwpfczfoodwuly +jghlinczhtaxifau +svjejifbidnvvdvy +rxmbsnaqhzcnbfcl +vveubmiecvdtrket +sbihpvrcnzjtgfep +iqbuljuxkwrlebvw +ptrhvxrpezqvmmvv +duwzugnhktpiybjw +lijafjnujfeflkva +coylvegferuuyfop +fowsjrgammrqkkof +pgmcruaioccmbrbz +osejwflxagwqtjoi +otqflckqgxzvtper +slwyntdcrncktoka +hzcdzsppcfkrblqg +jksdmmvtzkqaompg +galwwwgugetdohkg +zbghtjvuikmfjuef +dmqwcamjtlcofqib +zbczldlfdzemxeys +mdlqoklybhppdkwe +tuyajhkexrrrvnlb +ylfolaubymxmkowo +nnsyrfnoyrxswzxn +zkhunhhhigbsslfk +spbokzdfkbmflanz +zmzxvrwdhiegfely +imywhfczvmgahxwl +fnvabvxeiqvsarqq +yschramprctnputs +ubyjrgdzsvxzvouj +qnvdhpptympctfer +smipxcntyhjpowug +ouhjibgcmotegljy +zpflubaijjqqsptz +fgysnxrnfnxprdmf +pbpznrexzxomzfvj +thhzjresjpmnwtdv +sbmokolkhvbfqmua +sxxpdohxlezmqhhx +pevvsyqgoirixtqh +wdxrornmhqsbfznb +zjqziqbctxkshqcn +nbqcwpzfwfaahylk +bxbvkonpcxprxqjf +xplbpqcnwzwqxheb +prsakggmnjibrpoy +xoguxbpnrvyqarjl +ilrgryrmgwjvpzjy +efwrmokaoigjtrij +yhcncebopycjzuli +gwcmzbzaissohjgn +lggmemwbbjuijtcf +fkqedbfrluvkrwwl +jcbppekecevkwpuk +onvolrckkxeyzfjt +zzousprgrmllxboy +cajthmamvxuesujl +rmiozfsikufkntpg +lvekypkwjbpddkcv +dwaqzfnzcnabersa +pcdsskjopcqwhyis +uabepbrrnxfbpyvx +yxlgdomczciiunrk +ccerskfzctqxvrkz +edvmkntljlncwhax +xtcbwecdwygrvowo +axqgqjqkqwrgcqot +tyjrynolpzqwnjgj +thrtmlegdjsuofga +mpgoeqkzzqqugait +emuslxgoefdjyivl +klehpcehdznpssfb +xfgvugyrdxolixkc +acenyrbdwxywmwst +yqgperajsfsamgan +dbjxlnumrmhipquw +hsnhirmswcenewxm +qehqkbhmgucjjpwo +gprjdglsbtsfzqcw +wvqkyrkoratfmvfi +myhzlerupqbduqsl +couyazesiuhwwhht +scxzehubxhkfejrr +gqlitwfriqkmzqdd +pxtbmqelssoagxko +dzhklewjqzmrfzsw +yxgeypduywntnbji +kwzbgzhkzbgedlfh +vukmuyfstgmscuab +vcmaybfvdgwnasgt +qmybkqqdhjigzmum +cbnuicuncvczyalu +qdgpsdpdlgjasjqr +kdzxqqheurupejjo +mcatrxfchbqnxelm +badunwkeggdkcgco +ntaeanvcylpoqmxi +ghnyfytpzgvuokjn +ozepydixmjijdmts +qefcfwzdhwmcyfvp +ycyktmpaqgaxqsxt +edpizkxnsxeeebfl +uwciveajsxxwoqyr +rbvjkljpxtglqjsh +nbplrskduutrptfk +vewrbadvkseuloec +upaotnjxquomoflx +qfwxkinrousqywdd +mqzxvvskslbxvyjt +oxicszyiqifoyugx +bkitxwzjpabvhraj +ydrbyjecggynjpir +hezyteaublxxpamq +hxkuektnoovsehnd +cwtbbavnhlpiknza +qrwvkhbyasgfxwol +qryjbohkprfazczc +wjksnogpxracrbud +znmsxbhliqxhvesr +gkippedrjzmnnwkp +pklylwsnsyyxwcwg +osdpwbxoegwaiemr +kpslrrrljgtjiqka +vuqkloqucpyzfxgk +bvtdsisgvkuzghyl +qlcayluuyvlhdfyy +kbimqwnzanlygaya +nvoeanlcfhczijed +kqvcijcuobtdwvou +pmhdpcmxnprixitl +yueilssewzabzmij +zqxhafrvjyeyznyg +mhdounmxkvnnsekx +hnacyglnzicxjakg +iaxfdqibnrcjdlyl +iypoelspioegrwix +uiqouxzmlnjxnbqt +kslgjfmofraorvjo +bgvotsdqcdlpkynk +huwcgxhvrrbvmmth +vpqyfnkqqjacpffw +hpjgdfovgmrzvrcl +vbntbhbvdeszihzj +nrbyyuviwyildzuw +wckeoadqzsdnsbox +xgsobwuseofxsxox +anvhsxdshndembsd +iygmhbegrwqbqerg +ylrsnwtmdsrgsvlh +zvvejnrarsavahvc +yncxhmmdtxxeafby +kekgiglblctktnes +uoqgymsrlrwdruzc +saaoymtmnykusicw +bqvcworpqimwglcp +zbpgtheydoyzipjv +pkykzslwsjbhcvcj +jhwxxneyuuidrzvl +pafeyajcrlehmant +klszcvtmcdeyfsmj +ledsltggvrbvlefn +hubpbvxknepammep +gthxhaapfpgtilal +jtfhbozlometwztj +jrhshycyenurbpwb +fyaxbawrsievljqv +lgfcgbenlqxqcxsd +dhedabbwbdbpfmxp +mxzgwhaqobyvckcm +qboxojoykxvwexav +jcpzfjnmvguwjnum +ohpsxnspfwxkkuqe +nyekrqjlizztwjqp +thuynotacpxjzroj +wymbolrlwosnbxqx +iyaqihnqvewxdtjm +hdvdbtvfpdrejenu +gtjscincktlwwkkf +wtebigbaythklkbd diff --git a/y2015/src/bin/d5.rs b/y2015/src/bin/d5.rs new file mode 100644 index 0000000..8e0e29c --- /dev/null +++ b/y2015/src/bin/d5.rs @@ -0,0 +1,20 @@ +use std::fs; + +use y2015::days::d5; + +fn main() { + part1(); + part2(); +} + +fn part1() { + let root = env!("CARGO_MANIFEST_DIR"); + let content = fs::read_to_string(format!("{root}/resources/5_input.txt")).unwrap(); + println!("{}", d5::process_part1(&content)); +} + +fn part2() { + let root = env!("CARGO_MANIFEST_DIR"); + let content = fs::read_to_string(format!("{root}/resources/5_input.txt")).unwrap(); + println!("{}", d5::process_part2(&content)); +} diff --git a/y2015/src/days/d5.rs b/y2015/src/days/d5.rs new file mode 100644 index 0000000..bfcae1c --- /dev/null +++ b/y2015/src/days/d5.rs @@ -0,0 +1,105 @@ +use std::collections::HashMap; + +const DISALLOWED: [(u8, u8); 4] = [(b'a', b'b'), (b'c', b'd'), (b'p', b'q'), (b'x', b'y')]; +const VOWELS: [u8; 5] = [b'a', b'e', b'i', b'o', b'u']; + +pub fn process_part1(input: &str) -> i32 { + input + .lines() + .map(|line| line.as_bytes()) + .map(|line| { + let mut num_vowels = 0; + let mut has_double = false; + if VOWELS.contains(&line[0]) { + num_vowels += 1; + } + for window in line.windows(2) { + if DISALLOWED.contains(&(window[0], window[1])) { + return 0; + } + if window[0] == window[1] { + has_double = true; + } + if VOWELS.contains(&window[1]) { + num_vowels += 1; + } + } + if num_vowels >= 3 && has_double { + return 1; + } + 0 + }) + .sum() +} + +// used the following solution to debug +// cat input | grep "\(..\).*\1" | grep "\(.\).\1" | wc -l +pub fn process_part2(input: &str) -> i32 { + input + .lines() + .map(|line| line.as_bytes()) + .map(|line| { + let mut pairs = HashMap::new(); + let mut has_sandwich = false; + for window in line.windows(3) { + if window[0] == window[2] { + has_sandwich = true; + break; + } + } + if !has_sandwich { + return 0; + } + let mut last_pair = "".to_string(); + let mut is_valid = true; + for window in line.windows(2) { + let pair = String::from_utf8(window.to_vec()).unwrap(); + if pair == last_pair && is_valid { + is_valid = false; + continue; + } + is_valid = true; + pairs + .entry(pair.clone()) + .and_modify(|counter| *counter += 1) + .or_insert(1); + last_pair = pair; + } + for (_, count) in pairs.into_iter() { + if count >= 2 { + println!("{}", String::from_utf8(line.to_vec()).unwrap()); + return 1; + } + } + 0 + }) + .sum() +} + +#[cfg(test)] +mod tests_5 { + use super::*; + + const INPUT1: &str = "ugknbfddgicrmopn +aaa +jchzalrnumimnmhp +haegwjzuvuyypxyu +dvszwmarrgswjxmb"; + + #[test] + fn it_works() { + let result = process_part1(INPUT1); + assert_eq!(result, 2); + } + + const INPUT2: &str = "qjhvhtzxzqqjkmpb +xxyxx +uurcxstgmygtbstg +ieodomkazucvgmuy"; + + #[test] + fn part2() { + let result = process_part2(INPUT2); + assert_eq!(result, 2); + } +} diff --git a/y2015/src/days/mod.rs b/y2015/src/days/mod.rs index 61f448e..e2123e8 100644 --- a/y2015/src/days/mod.rs +++ b/y2015/src/days/mod.rs @@ -2,3 +2,4 @@ pub mod d1; pub mod d2; pub mod d3; pub mod d4; +pub mod d5;