From 3e2cbb4454a484632a49e37250a76fd3d59c69f1 Mon Sep 17 00:00:00 2001 From: Alpha Chen Date: Sun, 3 Jan 2016 20:26:13 -0800 Subject: [PATCH] [rust] Day 5.0 --- rust/Cargo.lock | 32 ++ rust/Cargo.toml | 1 + rust/input/day_05.txt | 1000 +++++++++++++++++++++++++++++++++++++++++ rust/src/day_05.rs | 54 +++ rust/src/lib.rs | 14 +- rust/src/main.rs | 4 +- 6 files changed, 1098 insertions(+), 7 deletions(-) create mode 100644 rust/input/day_05.txt create mode 100644 rust/src/day_05.rs diff --git a/rust/Cargo.lock b/rust/Cargo.lock index 46ab38e..2435fd7 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -2,6 +2,7 @@ name = "advent_of_code" version = "0.1.0" dependencies = [ + "regex 0.1.44 (registry+https://github.com/rust-lang/crates.io-index)", "rust-crypto 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -14,6 +15,14 @@ dependencies = [ "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "aho-corasick" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "memchr 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "gcc" version = "0.3.21" @@ -42,6 +51,14 @@ name = "libc" version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "memchr" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "rand" version = "0.3.12" @@ -52,6 +69,21 @@ dependencies = [ "winapi 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "regex" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "aho-corasick 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "regex-syntax 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "regex-syntax" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "rust-crypto" version = "0.2.34" diff --git a/rust/Cargo.toml b/rust/Cargo.toml index ece5289..8c4e34e 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -4,4 +4,5 @@ version = "0.1.0" authors = ["Alpha Chen "] [dependencies] +regex = "0.1" rust-crypto = "^0.2" diff --git a/rust/input/day_05.txt b/rust/input/day_05.txt new file mode 100644 index 0000000..afc7b3d --- /dev/null +++ b/rust/input/day_05.txt @@ -0,0 +1,1000 @@ +rthkunfaakmwmush +qxlnvjguikqcyfzt +sleaoasjspnjctqt +lactpmehuhmzwfjl +bvggvrdgjcspkkyj +nwaceixfiasuzyoz +hsapdhrxlqoiumqw +lsitcmhlehasgejo +hksifrqlsiqkzyex +dfwuxtexmnvjyxqc +iawwfwylyrcbxwak +mamtkmvvaeeifnve +qiqtuihvsaeebjkd +skerkykytazvbupg +kgnxaylpgbdzedoo +plzkdktirhmumcuf +pexcckdvsrahvbop +jpocepxixeqjpigq +vnsvxizubavwrhtc +lqveclebkwnajppk +ikbzllevuwxscogb +xvfmkozbxzfuezjt +ukeazxczeejwoxli +tvtnlwcmhuezwney +hoamfvwwcarfuqro +wkvnmvqllphnsbnf +kiggbamoppmfhmlf +ughbudqakuskbiik +avccmveveqwhnjdx +llhqxueawluwmygt +mgkgxnkunzbvakiz +fwjbwmfxhkzmwtsq +kzmtudrtznhutukg +gtvnosbfetqiftmf +aoifrnnzufvhcwuy +cldmefgeuwlbxpof +xdqfinwotmffynqz +pajfvqhtlbhmyxai +jkacnevnrxpgxqal +esxqayxzvortsqgz +glfoarwvkzgybqlz +xdjcnevwhdfsnmma +jyjktscromovdchb +pvguwmhdvfxvapmz +iheglsjvxmkzgdbu +lwjioxdbyhqnwekv +zcoguugygkwizryj +ogvnripxxfeqpxdh +hkvajhsbfnzsygbm +cnjqeykecopwabpq +wojjtbcjinoiuhsj +kpwpvgxbyzczdzjq +wrvhylisemlewgzk +uiezkmnhilfzahtm +mucteynnuxpxzmvt +zaiwbgxefusfhmst +apptbogpxivjwink +qryboarjtwjhjgjb +irehxupgyseaahzd +fobstqxguyubggoh +ysriumfghtxtfxwe +auchdmasvfeliptw +mztuhefcrnknyrdl +tyjmkhihbwabjtaa +yquzkdtgsljkaebw +almvdvofjtkyzbmd +emqftiuqqpdwwbrv +hrrhmqfpepvbawvw +atrkgykycvgxbpyb +dhthetnealksbdan +zzqafhgicubptiyo +qdtaieaziwhbttnw +kyskgapdgqrtrefw +edwzlpqztpydmdlr +awszjnlmvlyqsuvl +kcrtmtshtsgixvcp +jtaskgkijivbbkri +mmggfwapsetemiuj +itagrrnjbnmhgppd +uqmbezechbrpbnqq +nnyimvtascflpzsa +knqeimypkdttyudj +vgoiyvtvegwyxjjd +qubzdxsbecktzrho +zehojtvktsbbxijb +xepmjrekwcgoxyoh +bnptxnocbpbqbyeq +sfvynsywscbnymos +dsltfbpcmffbluba +kncrlzlmkikylppa +siwudrvmildgaozv +jhhefbvbvneqzvtc +lqjgztxitbuccqbp +himmwlbhjqednltt +vwognchyertnnfil +eejakhapkbodrntf +qxuijkkhhlskgrba +aankpfxxicfpllog +vuxykvljyqexfhrn +epgygflbxlbwybzq +zuxmwvetmvcszayc +xttwhfqmemgtjnkf +hftwldmivyfunfvl +bejlyxfamzliilrj +zkehazcxyyvtrxti +dsgafehmcfpycvgz +igremmqdojqdvwmb +swnjzvmhcslvkmiw +fchzbfbmtqtxmaef +xwjmyyrlznxrcytq +brwcwzpcvbwdrthl +fvrlridacsiojdmb +mhsturxdlmtxozvy +usxvqyrwywdyvjvz +gwazuslvmarfpnzm +rgkbudaqsnolbcqo +dpxvlbtavdhdedkj +nnqmjzejhodyfgyd +ozoazxkfhujgtzvy +psdgvhzdiwnuaxpl +tznkilxpogbzgijz +wnpytcseirtborhh +lhauurlfsmagfges +oqfbzixnlywkzwwy +yoehapoyjpakziom +vtjftdcsfdzbmtrn +zcshfnodiwixcwqj +wapbxpaxgjvtntkm +qfyypkyvblrtaenh +bsxhbxkovgukhcza +kitdmvpiwzdonoyy +slkbhxmehzavbdsf +dovzjouqkzkcmbkl +qpbigdcqkfnfkxvq +eaiaquhnesvtcdsv +mhbezlhqojdsuryj +dqprkkzxlghkoccx +xqepmorryeivhrhm +frwmrjpezwmjflvf +gjpfgwghodfslwlf +fzyvajisdjbhfthq +pvzxkxdscdbilrdb +mtaxmqcnagmplvnm +rlyafujuuydrqwnc +gvqvrcxwyohufehq +lmrkircgfrfusmfd +ovlpnkxcpimyaspb +xhyjremmqhdqywju +pxfczlhpzbypfarm +utjhprzhtggausyp +utzkkzlnyskjtlqh +cecbcnxpazvkedic +xwvoaggihrbhmijq +krredhmtwlfmyagw +lwfhxgbknhwudkzw +vyczyvuxzmhxmdmn +swcoaosyieqekwxx +waohmlfdftjphpqw +gaclbbfqtiqasijg +ybcyaxhluxmiiagp +xgtxadsytgaznndw +wzqhtjqpaihyxksm +fdwltsowtcsmsyhm +rpoelfbsararhfja +tswgdacgnlhzwcvz +xjgbhdlxllgeigor +ksgthvrewhesuvke +whgooqirdjwsfhgi +toztqrxzavxmjewp +hbkayxxahipxnrtl +lazimkmdnhrtflcu +ndoudnupbotwqgmr +niwuwyhnudxmnnlk +hlmihzlrpnrtwekr +wzkttdudlgbvhqnc +rfyzzgytifkqlxjx +skddrtwxcyvhmjtb +mljspkvjxbuyhari +xwkhozaoancnwaud +nookruxkdffeymdz +oiqfvpxmcplyfgoa +qoxggshmrjlzarex +lsroezewzkrwdchx +nkoonmvdydgzspcl +lygxeqztdqklabov +jempjyzupwboieye +hpdaqkhjiddzybly +cvcizjlnzdjfjlbh +vaaddsbkcgdjhbkj +pjxmtxoyrkmpnenf +ujqdvyqnkbusxlps +miyvzkzqploqaceb +gapcsbkulicvlnmo +xqpcyriqhjhaeqlj +ipumdjwlldzqhmgh +swdstecnzttmehxe +ucmqordmzgioclle +aywgqhmqlrzcxmqx +ptkgyitqanvjocjn +wcesxtmzbzqedgfl +rnetcouciqdesloe +chpnkwfdjikqxwms +onpyrjowcuzdtzfg +tydnqwaqwkskcycz +dhamguhmkjzzeduy +oecllwyrlvsyeeuf +gsukajpoewxhqzft +sgdnffdixtxidkih +pqqzjxzydcvwwkmw +wnjltltufkgnrtgm +hylaicyfrqwolnaq +ovfnugjjwyfjunkm +xknyzsebmqodvhcl +uwfmrjzjvvzoaraw +zaldjvlcnqbessds +zphvjuctrsksouvz +ceqbneqjwyshgyge +wmelhaoylbyxcson +nghuescieaujhgkj +dhjmflwwnskrdpph +exvanqpoofjgiubf +aidkmnongrzjhsvn +mdbtkyjzpthewycc +izctbwnzorqwcqwz +hrvludvulaopcbrv +mrsjyjmjmbxyqbnz +sjdqrffsybmijezd +geozfiuqmentvlci +duzieldieeomrmcg +ehkbsecgugsulotm +cymnfvxkxeatztuq +bacrjsgrnbtmtmdl +kbarcowlijtzvhfb +uwietqeuupewbjav +ypenynjeuhpshdxw +fwwqvpgzquczqgso +wjegagwkzhmxqmdi +vocvrudgxdljwhcz +nnytqwspstuwiqep +axapfrlcanzgkpjs +lklrjiszochmmepj +gxadfpwiovjzsnpi +qidsjxzgwoqdrfie +wgszciclvsdxxoej +kwewlmzxruoojlaq +ywhahockhioribnz +ucbqdveieawzucef +mdyyzmfoaxmzddfv +hsxnabxyqfzceijv +vivruyvbrtaqeebr +jxfeweptjtgvmcjc +mmypqxmpurhculwd +mpiaphksvctnryli +xqzqnuxmuzylkkun +fndmtefjxxcygtji +dnorqlldvzqprird +nutokyajmjpwjaqu +vlupfperqyqkjcaj +dgihjeokrphkpdnk +nvbdyrlheqzixuku +mhrkntnxvsmvrpka +kvhkyanlhhymwljf +fhipumtegqfgeqqw +vpfjgveycdefuabu +kzincljffncylcsf +tsezxymwmjtyegqw +wxhcdrqedkdcwxli +ueihvxviirnooomi +kfelyctfvwyovlyh +horzapuapgtvzizz +iiqkdpmfvhwwzmtj +rsaclclupiicstff +quwkkhrafypkaoum +gyrgkgmwqfkeudfe +noydhbqacwptyfmy +efwwuipzgtkwffhf +suyojcitomdxsduh +lbcxnsykojkufkml +zpglsvoutvzkgdep +usgrufyvgsbsmbpr +katrrwuhwvunjqor +btngwrpcxoyfbgbc +bxjscjdiowjrkpns +nwxvnfrnlkgqxvhf +ikhyqkvljucgdlag +xibnxsjopmxvflkl +mzplumcfivqcjqnz +jqflcxoxzlbwlxry +fcscvmfepdxrshxe +wlpffwunffklzbuc +emvrlqajjgwzfmle +rhaheurtzrfoqkyq +ifuuhpxmadaysfsx +ncyfvleyzqntpcoo +zeogmyaqccmtvokd +jqppbzebppdnpurn +xixarswxsiwjzgni +ezruwzajsoombphs +hmiqfeizyprielxf +jnaoxljnftymsfey +extgzrxzovlsixnf +yhyfmovvlrwoezsv +ffnybaolppuzpjym +pqowimdiusccaagn +jgceiosiihpjsmnu +hkoexeaopebktngx +njhzuvsygymejqav +yjkgcclgtvushcfk +gmbjxhnkkxlihups +pdlwysadiebsidjz +omrwmgzulfoaqros +ofvvgdezwvcffdcy +otytpuklhxcpxhgd +eyfaosxdauumvlux +mvdthjfstrlqlyuo +mdgdchgnlxaxspdm +bakjezmhbwqxzevd +msakswaphdwaodhg +vjcqscgdbnsxdllh +jjywaovewbuzreoj +nqvplhwacylifvwk +lpwmpixbxysmsign +flcvbpxrchcpbgcb +qjpkeuenenwawlok +bnqkflfmdmntctya +fzsgzpoqixvpsneq +icwfdisutoilejld +relchofohnkwbumi +aljalgdaqwhzhfwr +cahkvnwnbwhodpqs +dnrzeunxiattlvdm +nsmkhlrpwlunppjs +mqqsexlwfqnogwub +tfavelkqrtndpait +ooguafrnmprfxcnz +ntynkiordzxtwrqa +rkkyzlxekqqlkvym +ofxcivdnwcmgfnme +ywotqwbrqxlrnobh +nrbbiypwhrqihvev +flqsjixxtydheufs +lcfrfzypstrqctja +hyzbuzawuzjrynny +exfbywcnstebnvmq +vydzwnbmcihvqrnj +qmwqaaylinzrdmiw +lpxpztpvfggspeun +lhxmqqbracsuyrfm +zgkwsrabaseidbrw +yjlmbhbqsqgszsun +mqfzqtbxtuteabtd +izomzdmcqmfrevwd +iqijrlqurdwrkoln +fxhqzpgoxxjkkhql +oulwontmgrjeopnk +edaigfydjexvzzvj +vjhybiklxpxjqpwc +ypxfbfnpbmqmwtte +xzvcsgasztrxdzud +rpulqmobptfarboo +palacmdijxzzykrf +jmllwukplufohiby +dnswayomusiekfmy +sxbrjqtqgzzwhcfo +lylvndsgbnbqiejm +jaxxhoulxnxnaenr +nblissutfazbcpwn +zmlsjszzldvbiacr +kewojtlchfkclqwk +eqvfjasddggvfame +yibzqlvxtraxpdon +dgnbxsbmdrtyvaac +uoxrcxfimhgtxqhy +xfdxalrwcwudlviq +xmtbdklqptoswpwl +zezyopzdztdjerfl +xuzluhjsqvhytgbc +qdjtmeckispmgzki +phakupesplzmmmvc +gpuoqfffumzszybn +bhywxqkrrlwuebbw +ibvwgoyvelzenkzl +ncohvvbmiekbaksa +fzuvqzvxvdbeirrp +lshtzniokucwojjd +punrduvlnrulkium +gnfpikidnfobrrme +vxkvweekmnvkzgyl +rhydssudkcjlqgxn +cjtqvlaahohcgumo +jwzmfyinsfwecgcb +blpeseqhlzfilpuf +jvtpjkyokzcvagon +qjomincbcobjczpe +ugsyzkzgdhxtmsfz +hleaqgwzqjwajcra +coumfghptpnxvvov +hqpnbupnzwpdvgqd +cpouyodqxgviasem +lljvxeyozckifhfd +huqtnvutdyfgwtwa +yenlveuynmlmmymu +ojdyufkomxiwjmbf +spjzgvcwvzgffjkk +vxykmjhyvmhyssbp +tazdeqggfcjfvwwn +uumwcngwcytvpufx +avovuzkrevloneop +owczrtbnrvjfemkt +hzpugcanaxyvaokj +iishlodnxvjtgzyn +qosdonclrnxirham +eonqlnwevahydddg +ryqmnuikftlxuoqy +whqepbcwabzbthha +vekisvnwhgpyemxr +lrwxzoamnvpnlhap +ywepvqthnorfswjv +evqwvsoazmwyypjy +bgwoojddubppmjxf +jypkfrthzgtyeddi +tynabbhfjzkrqsju +adxstbfqheuqbcuk +gqwqiocdyqoiblrx +ybuddlyuskdlegxv +luwynbsmpgyeqsbr +ltyqgqoyljibqndo +jaedpajzphfybajh +epglnrxofptsqvmy +zjdpxkngfkstxbxh +ekegphcwanoickfu +cqvhuucvejqirvfs +uqudnnqumsqcgefo +qnzunermlnpcfflo +ovyxaniqaawzfuxx +djekxcezjowdhopq +bwtwbmdehrhpjnlk +nilsnlacerweikfa +hyrigsrmsrzcyaus +gvmdmgddduylmxic +ewzovdblhmjgjwsk +ojjfsknlonzguzlq +yjgfruvpjvlvrvvq +cyoryodwyhzwprbv +crsjclrurcquqgut +sjhfhobwtojxcmem +ibxfjudilmdeksea +uqbhdbjoeupyhbcz +uqbxigzxuxgmjgnw +jashafmtzrhswirg +dexiolovaucyooka +czjbwwnlwcoqnoiu +ojigosazigfhttjc +zfiqtgrqbmftknzn +dlzbmvmolssbqlzl +sgmchcurrutdtsmw +scdwjqsdohcdrwry +cgtdvecqwplpprxn +iiplenflfczaktwi +wmgnwfxfcjhyeiqg +giihshowtcatecvl +nqhzfincclumvkaz +kxstpzgdfvepionc +agbhxcijxjxerxyi +hmgfqevgdyvisyvs +tthakmvpowpvhtao +ottalcghygpaafbo +aplvozayycremgqg +dbjxlnaouxqtdpfz +peeyallzjsdvpalc +ndtdjyboixuyhfox +llabnbcobexfoldn +cweuvfnfyumbjvxr +ewkhhepaosalnvkk +pivyiwsiqpwhagyx +auzsnwdcerfttawt +grbfrekupciuzkrt +byfwzadtzrbndluf +lluypxjeljzquptk +pskwsnhqanemtfou +sxvrtqqjdjkfhhrm +ulsmqgmshvijyeqh +qigofesfhekoftkf +zhatniakqtqcxyqa +uuczvylgnxkenqee +mlitvtuxknihmisc +srrtrxdvcokpyfmz +osispuucklxcfkeb +vqhazlaulmnpipql +umkiueljberqhdig +knvpbkbvgoqzwprp +nbsocqikhuvsbloj +wjnpepjkzkednqbm +agbhmytsofuyqcor +gvogzhkkpxyfecko +ardafguxifeipxcn +yiajcskbgykyzzkw +sejunbydztyibnpq +dqrgfggwcnxeiygy +xnqqwilzfbhcweel +jjtifhlvmyfxajqi +gwszrpgpmbpiwhek +kydzftzgcidiohfd +efprvslgkhboujic +kecjdfwqimkzuynx +rildnxnexlvrvxts +dlnhjbqjrzpfgjlk +qluoxmzyhkbyvhub +crydevvrjfmsypbi +dosaftwumofnjvix +pwsqxrfwigeffvef +nzyfmnpwqyygjvfx +iccbckrkxlwjsjat +bmputypderxzrwab +bhuakynbwnlreixb +qmrzfyqjiwaawvvk +juvtixbkwyludftn +zapmjxmuvhuqlfol +paiwrqjhpjavuivm +tsepfbiqhhkbyriz +jpprewufiogxoygk +mmapyxbsugcsngef +pduhmgnepnpsshnh +aetndoqjvqyjrwut +fnfvlorhwpkkemhz +gedfidpwvoeazztl +beclvhospgtowaue +wsclsvthxustmczm +tjbxhnpniuikijhe +rhetyhvfcemponeg +mavonujurprbeexi +argbrpomztrdyasa +bzvtffbtygjxmkvh +maqyqkhsqgzfzvve +seeirbiynilkhfcr +wxmanwnozfrlxhwr +dieulypsobhuvswb +nxevassztkpnvxtb +jclxuynjsrezvlcy +xlolzyvgmwjsbmyf +tguzoeybelluxwxc +fkchoysvdoaasykz +cyynwbfcqpqapldf +rhifmzpddjykktuy +ndvufsyusbxcsotm +txutnzvdsorrixgg +qjoczhukbliojneu +ufhwujotncovjjsz +kclsgsdwcrxsycbr +yscwmlrdaueniiic +nxhivrovpkgsmugb +fdxqfyvwwvgeuqkv +femtamfylysohmpr +amsyzslvyxsoribh +nhmqxncwsonhgbcz +uomqsvcbpthlmcue +kxtfapcqrnjkkslj +xtieihonlfubeync +adpcjqxgydulchgj +cjynnzsmmujsxxpd +neeapmzweidordog +szoivgqyqwnyjsnk +uwgrtzaqezgphdcu +ptpgttqxocjwxohi +fhltebsizfwzpgpf +emmsazsidspkhgnh +dxcprkbcjeqxqzgn +tpxzqwxbzwigdtlt +afsmksnmzustfqyt +xyehnftstacyfpit +vcrfqumhjcmnurlw +rrznpjzcjgnugoch +gbxnzkwsjmepvgzk +jwobshgwerborffm +zmuvfkhohoznmifs +buyuwgynbtujtura +bevncenmpxfyzwtf +hqqtcrhzfsrcutjh +kbpzshllpiowepgc +alspewedcukgtvso +xvsvzzdcgjuvutrw +pmwulqraatlbuski +abuzsiinbueowpqn +oedruzahyfuchijk +avhcuhqqjuqkesoq +azqgplkzsawkvnhb +rjyoydogkzohhcvx +aezxwucqvqxuqotb +kxobnsjvzvenyhbu +nnjoiilshoavzwly +aijttlxjrqwaewgk +cvsaujkqfoixarsw +zngtoacpxcsplgal +qhkxliqtokvepcdv +aixihrtdmxkfvcqw +owbgdgdymxhhnoum +tajsagmruwzuakkd +ckrfduwmsodeuebj +alfdhuijuwyufnne +xpchlkijwuftgmnm +rwcrvgphistiihlg +xdaksnorrnkihreq +akeschycpnyyuiug +rgputhzsvngfuovz +lerknhznuxzdhvre +mqiqmyladulbkzve +csnmupielbbpyops +kwgrwgmhfzjbwxxz +npwtvbslvlxvtjsd +zxleuskblzjfmxgf +hexvporkmherrtrn +rhtdhcagicfndmbm +qhnzyuswqwoobuzz +dpvanjuofrbueoza +kjcqujmnhkjdmrrf +gholddsspmxtpybg +jihlvyqdyzkshfsi +zuviqmuqqfmtneur +kzexjowatvkohrtx +wgijnfhibsiruvnl +zevkrkmhsxmicijb +khxrcteqourjvoxa +ylpxlkcnenbxxtta +zrfsvctbojjkpvtw +nlzbudxibnmcrxbt +cqnscphbicqmyrex +ywvdohheukipshcw +riwatbvjqstubssf +idlztqqaxzjiyllu +sdpdgzemlqtizgxn +rjtbovqlgcgojyjx +fnfrfwujmjwdrbdr +osnppzzmrpxmdhtj +ljhwngclvydkwyoe +chwqkrkzrvjwarat +jmydkwpibkvmqlgs +zvhfmbxnlxtujpcz +jsnhsphowlqupqwj +fzhkkbpasthopdev +jerntjdsspdstyhf +gctwmaywbyrzwdxz +xemeaiuzlctijykr +xulrqevtbhplmgxc +yfejfizzsycecqpu +gboxrvvxyzcowtzm +lpvhcxtchwvpgaxp +wdiwucbdyxwnjdqf +qgwoqazzjlvnjrwj +prtlnkakjfqcjngn +fagvxsvjpuvqxniz +xacmxveueaakfbsm +ginvtonnfbnugkpz +qpvggsppewfzvwin +reoqnlzruyyfraxa +kolwtqhifjbbuzor +vrkcywvdhdprztww +ngdvyfmvjqhbzbxt +rooxeoilqzqjunmp +efxmdprtogtxgyqs +qrhjuqndgurcmwgu +ouitjprueefafzpl +kirdwcksqrbwbchp +fpumsmogojuywezo +lgjrgykywugzjees +xigioqcpjabpbdas +ewkhuprpqzikmeop +fgrgxsqeducigxvr +bclkursnqkzmjihl +jozidniwvnqhvsbc +oghcilcyozrmmpta +xbgmaungzcpasapi +iqowypfiayzbcvhv +opdehgwdgkocrgkf +zfzvdjeinlegcjba +vhakxvlcayuzukap +xyradgyiebpevnwe +eamhtflgedwyshkn +igteqdgchjeulfth +kwsfkigxzpbgdxod +vapnpsbdboiewpzp +wbuqhjsngxpqshen +vxxilouxuytitwgm +cpnwlkwnkeanqnet +wdmbtqvvlowftvgb +wjtmcecpyqzwpbqg +jnxmoxdhvsphcdeg +wabxfxpotoywwodn +mwbsoxzlqpqobvvh +coktshbyzjkxnwlt +rzhnggpslwzvyqrp +dgzuqbzarbutlkfx +wunajaiiwgijfvjh +uotdbcgmsvbsfqlb +kxdtlgmqbccjqldb +ngmjzjwvwbegehfr +cvpsabqfpyygwncs +wqluvqlhdhskgmzj +rbveperybfntcfxs +fbmoypqdyyvqyknz +zxpgzwnvmuvkbgov +yexcyzhyrpluxfbj +ltqaihhstpzgyiou +munhsdsfkjebdicd +plecvjctydfbanep +kjrxnnlqrpcieuwx +zbcdtcqakhobuscf +kgovoohchranhmsh +llxufffkyvuxcmfx +tgaswqyzqopfvxtw +kojcqjkdpzvbtjtv +xggdlkmkrsygzcfk +vvitpsnjtdqwyzhh +gcqjuwytlhxsecci +vbsghygcsokphnrg +vejqximdopiztjjm +hudqtwmwkviiuslp +vwswfvpcwwpxlyry +gxmfiehdxptweweq +qjmekjdcedfasopf +pqyxdxtryfnihphf +felnavctjjojdlgp +hbimufguekgdxdac +dhxhtnqgfczywxlr +pssottpdjxkejjrh +edieanguabapxyig +sciinanyqblrbzbb +irxpsorkpcpahiqi +qsxecaykkmtfisei +ivfwlvxlbnrzixff +hqxzzfulfxpmivcw +vvbpaepmhmvqykdg +cetgicjasozykgje +wuetifzdarhwmhji +gaozwhpoickokgby +eldnodziomvdfbuv +favpaqktqaqgixtv +twbcobsayaecyxvu +lzyzjihydpfjgqev +wnurwckqgufskuoh +fxogtycnnmcbgvqz +aetositiahrhzidz +dyklsmlyvgcmtswr +ykaxtdkjqevtttbx +kfmnceyxyhiczzjm +nnizopcndipffpko +yjmznhzyfinpmvkb +sljegcvvbnjhhwdd +zmkeadxlwhfahpwg +rwvcogvegcohcrmx +aguqwrfymwbpscau +vlusytjagzvsnbwe +smvzhburcgvqtklh +rfuprvjkhazrcxpv +megqlnoqmymcrclc +gvldhkewtmlwqvqv +awynhvtyziemnjoa +voprnvtnzspfvpeh +dhlguqwmunbbekih +goayirdhnjrfuiqi +eoghydfykxdslohz +chpippjykogxpbxq +hqbycjweqczwjwgf +pvefsrvwumrlvhmt +eghwdovaynmctktk +crwkxoucibumzawc +bzbtahvhkdigvvtj +bnbptgihhfubxhho +ddqmbwyfmfnjjaro +gvtswqyzazihctif +vmqctjpgadxztqqb +dgnndowtpeooaqqf +sxdvctfdtalufxty +ylgeexosibsmmckw +sxplpyskbpqnojvw +coarhxtsvrontyeg +fyoaurggjupvzvlv +jlyrkqsiwuggvjem +uwbsjoxonreuucyi +gihuqvwxovbgokes +dxzaaxupbcgnxcwf +gidrgmvyrlqqslve +csflmlvqmonoywpx +jkxkpixlythlacnk +ejkarcdkdslldugv +dbzmsusevohhjkmr +cbrqzualjpdtworc +kpgidqlmcbpfmmwu +zwghjuofexfowqam +ncdlxmcrsmsocetz +kfprzqacefifjkbd +swwzivrxulkhvldc +wgqejhigbjwunscp +rsstnwcyybfauqxu +qhngfxyhdqopyfgk +zrndpyyejsmqsiaj +xxknxwpvafxiwwjc +mmaahwgoiwbxloem +tabacndyodmpuovp +yriwomauudscvdce +duvyscvfidmtcugl +mgipxnqlfpjdilge +imeeqcdetjuhfjnw +dvkutrdofpulqkyh +jefvtlktxegpmbya +iyzudqgpvlzjfydh +giohapxnpaqayryd +qheqdprmnqlpztls +rdxhijmzegxkotoq +hdnmaspumdwnrcdz +wafpbgehbuzdgsnc +tbtrfztsferdmhsy +vusndcyjngtkrtmk +ilqblestzxebcifh +urfgjbjgzlrfsdlv +aptcdvpsqwleqttn +bigczjvzokvfofiw +zjnjeufonyqgkbpx +trcdebioegfqrrdi +jrdvdriujlmbqewt +jqrcmuxpwurdhaue +yjlermsgruublkly +zwarvgszuqeesuwq +xthhhqzwvqiyctvs +mzwwaxnbdxhajyyv +nclsozlqrjvqifyi +gcnyqmhezcqvksqw +deuakiskeuwdfxwp +tclkbhqqcydlgrrl +qbpndlfjayowkcrx +apjhkutpoiegnxfx +oaupiimsplsvcsie +sdmxrufyhztxzgmt +ukfoinnlbqrgzdeh +azosvwtcipqzckns +mydyeqsimocdikzn +itfmfjrclmglcrkc +swknpgysfscdrnop +shyyuvvldmqheuiv +tljrjohwhhekyhle +dayinwzuvzimvzjw +qgylixuuervyylur +klqqaiemurawmaaz +hdmzgtxxjabplxvf +xiivzelzdjjtkhnj +ktgplkzblgxwrnvo +gvbpyofzodnknytd +lqhlmnmhakqeffqw +ltzdbngrcxwuxecy +obxnfjeebvovjcjz +zexpwallpocrxpvp +tjpkkmcqbbkxaiak +qiedfixxgvciblih +qcxkhghosuslbyih +gnsfidwhzaxjufgm +xrghwgvyjakkzidw +tftftwedtecglavz +wquqczzkzqrlfngr +twibtkijpvzbsfro +bmplypdsvzuhrjxp +zanrfmestvqpwbuh +zonrhfqowyimcukm +kpvajjfmqpbhrjma +kujzluicngigjbtp +iusguantsrwxdjal +kwxeuylcnszswahw +visdhnkobxnemldu +rogeadmmaicwtabl +pxqycifbgevqudvs +osaiozyvlyddylqr +vffjxrolrpuxcatx +jbmsetccdrywssjd +qgxyhjfpbfifmvgc +npejgalglldxjdhs +mbbtqgmttastrlck +whapaqwdtpkropek +dulbdboxazfyjgkg +xaymnudlozbykgow +lebvqmxeaymkkfoy +bmicnfuubkregouj +dieatyxxxlvhneoj +yglaapcsnsbuvrva +bbpjaslqpzqcwkpk +xehuznbayagrbhnd +ikqmeovaurmqfuvr +ylyokwuzxltvxmgv +hqtfinrkllhqtoiz +pjmhtigznoaejifx +fqdbmowkjtmvvrmx +uvqtqfoulvzozfxv +rpajajukuxtchrjd +sznucejifktvxdre +ufvibsmoushmjbne +xirdqoshngthfvax +iafpkddchsgdqmzl +vmualmlduipvykzh +fnmuahmblwyceejb +ilsaapnswfoymiov +lenvylifraahaclv +cukqxlipuyxedqfh +zgwecslpniqvtvuz +cdcdfpsxuyrhsmag +dszjinhantnxgqra +ioimwotsgnjeacgt +dqcymnvjystbynhp +yibaudyfefbfgunx +cabslcvunjavqkbf +goymzvmgkvlsmugf +zxteiitpthzskjjx +agnxcnaqhjhlurzs +cvmgyxhhnykuxbmb +cgqmjexydmvgwxpp +sygjajofieojiuna +clpvxbrbjvqfbzvu +cbntswqynsdqnhyv +bztpbtwbefiotkfa +pnxccbgajvhyeybu +asyzrvgzumtuissa +facjyblvcqqginxa +rvwnucnbsvberxuv +ghrbeykzrxclasie +ekujtselepgjtaql +krtrzsmduhsifyiw +ticjswvsnyrwhpnt +clmjhsftkfjzwyke +lbxlcixxcztddlam +xhfeekmxgbloguri +azxqwlucwhahtvep +kitdjrwmockhksow +keznwwcusgbtvfrs +ljvzxoywcofgwajj +vebjnhnkcfzbhrcw +eqfcxkavstxcuels +ldattkyawjrvcido +bsqqeilshcwtqyil +foqqsxahfiozcqrw +liswfmuhzfbyzjhf +sulbdcyzmolapfbs +zuggzkelwxjpsgxb +betioxrgtnhpivcw +xmtbixstdipibhgs +ttvurgqmulryyaji +viobnljznzppfmxw +qlzabfopydtxrlet +tusvydegfxhaxolk +thoufvvfjferxhwp +cfyyzppfarjiilbs +jwmhxtgafkkgseqs +pqwuuaxbeklodwpt +vndyveahdiwgkjyx +ssrjgasfhdouwyoh +thbavfcisgvvyekf +yjdvxmubvqadgypa +tlbmcxaelkouhsvu +bonohfnlboxiezzr +rktlxcbkhewyvcjl +rsmoutcbcssodvsc +qszdratuxcrhsvoh +eypyfahpuzqwzwhi +yhkrleqmqlmwdnio +vpnvxusvmngsobmq +hkzyhopvxrsimzys +dblriiwnrvnhxykl +xkriqxkrprjwpncs +rcymltrbszhyhqti +mzbvneplsnpiztzn +vkqtnptgbqefvfoc +nwdtfiaozkcjtlax +crximadpvdaccrsm +lrbajafxwwnxvbei +rbexzesrytpwwmjf +stxwjarildpnzfpg +btamaihdivrhhrrv +acqbucebpaulpotl +dkjhzghxxtxgdpvm +rsbzwsnvlpqzyjir +mizypbwvpgqoiams +nvrslorjpqaasudn +wvexcpzmconqkbvk +rfwfumhjwzrvdzam +eaghdaqorkhdsmth +gtuntmpqaivosewh +nzlsmdgjrigghrmy +dhuvxwobpzbuwjgk +kkcuvbezftvkhebf +aeediumxyljbuyqu +rfkpqeekjezejtjc +wkzasuyckmgwddwy +eixpkpdhsjmynxhi +elrlnndorggmmhmx +ayxwhkxahljoxggy +mtzvvwmwexkberaw +evpktriyydxvdhpx +otznecuqsfagruls +vrdykpyebzyblnut +cnriedolerlhbqjy +uajaprnrrkvggqgx +xdlxuguloojvskjq +mfifrjamczjncuym +otmgvsykuuxrluky +oiuroieurpyejuvm \ No newline at end of file diff --git a/rust/src/day_05.rs b/rust/src/day_05.rs new file mode 100644 index 0000000..fa6be63 --- /dev/null +++ b/rust/src/day_05.rs @@ -0,0 +1,54 @@ +use std::io; + +use regex::Regex; + +use day::Day; + +pub struct Day05 { + input: String, +} + +impl Day05 { + fn is_nice(string: &String) -> bool { + Day05::has_three_vowels(string) && + Day05::has_double_letters(string) && + Day05::has_no_substrings(string) + } + + fn has_three_vowels(string: &String) -> bool { + let three_vowels = Regex::new(r"[aeiou].*[aeiou].*[aeiou]").unwrap(); + three_vowels.is_match(string) + } + + fn has_double_letters(string: &String) -> bool { + for win in string.as_bytes().windows(2) { + if win[0] == win[1] { + return true; + } + } + false + } + + fn has_no_substrings(string: &String) -> bool { + !vec!["ab", "cd", "pq", "xy"].iter().any(|&s| string.contains(s)) + } +} + +impl Day for Day05 { + fn new(input: String) -> Day05 { + Day05 { input: input } + } + + fn solve(&self) -> io::Result { + Ok(self.input.lines().filter(|&s| Day05::is_nice(&s.to_string())).count() as i32) + } +} + +#[test] +fn test_nice() { + assert!( Day05::is_nice(&"ugknbfddgicrmopn".to_string())); + assert!( Day05::is_nice(&"aaa".to_string())); + assert!(!Day05::is_nice(&"jchzalrnumimnmhp".to_string())); + assert!(!Day05::is_nice(&"haegwjzuvuyypxyu".to_string())); + assert!(!Day05::is_nice(&"dvszwmarrgswjxmb".to_string())); +} diff --git a/rust/src/lib.rs b/rust/src/lib.rs index 6181391..9512e1f 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -1,4 +1,5 @@ extern crate crypto; +extern crate regex; macro_rules! import_day { ( $( $d:ident ),* ) => { @@ -9,8 +10,11 @@ macro_rules! import_day { } } -import_day!(day, - day_01, - day_02, - day_03, - day_04); +import_day! { + day, + day_01, + day_02, + day_03, + day_04, + day_05 +} diff --git a/rust/src/main.rs b/rust/src/main.rs index 8408257..552a763 100644 --- a/rust/src/main.rs +++ b/rust/src/main.rs @@ -19,7 +19,7 @@ fn read_input(filename: &str) -> Result { } fn main() { - let input = read_input("day_04").unwrap(); - let day = Day04::new(input); + let input = read_input("day_05").unwrap(); + let day = Day05::new(input); println!("{}", day.solve().unwrap()); }