From cab4e2974dfb386b9c67912f9bf61ea0aea3f64d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tristan=20Dani=C3=ABl=20Maat?= Date: Sun, 6 Dec 2020 21:00:40 +0000 Subject: [PATCH] Complete day 6 --- day-6/.gitignore | 1 + day-6/Cargo.lock | 78 ++ day-6/Cargo.toml | 10 + day-6/input | 2087 +++++++++++++++++++++++++++++++++++++++++++++ day-6/src/main.rs | 137 +++ 5 files changed, 2313 insertions(+) create mode 100644 day-6/.gitignore create mode 100644 day-6/Cargo.lock create mode 100644 day-6/Cargo.toml create mode 100644 day-6/input create mode 100644 day-6/src/main.rs diff --git a/day-6/.gitignore b/day-6/.gitignore new file mode 100644 index 0000000..b83d222 --- /dev/null +++ b/day-6/.gitignore @@ -0,0 +1 @@ +/target/ diff --git a/day-6/Cargo.lock b/day-6/Cargo.lock new file mode 100644 index 0000000..e508f5f --- /dev/null +++ b/day-6/Cargo.lock @@ -0,0 +1,78 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "day-6" +version = "0.1.0" +dependencies = [ + "indoc", +] + +[[package]] +name = "indoc" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47741a8bc60fb26eb8d6e0238bbb26d8575ff623fdc97b1a2c00c050b9684ed8" +dependencies = [ + "indoc-impl", + "proc-macro-hack", +] + +[[package]] +name = "indoc-impl" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce046d161f000fffde5f432a0d034d0341dc152643b2598ed5bfce44c4f3a8f0" +dependencies = [ + "proc-macro-hack", + "proc-macro2", + "quote", + "syn", + "unindent", +] + +[[package]] +name = "proc-macro-hack" +version = "0.5.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" + +[[package]] +name = "proc-macro2" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "quote" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "syn" +version = "1.0.53" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8833e20724c24de12bbaba5ad230ea61c3eafb05b881c7c9d3cfe8638b187e68" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "unicode-xid" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" + +[[package]] +name = "unindent" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f14ee04d9415b52b3aeab06258a3f07093182b88ba0f9b8d203f211a7a7d41c7" diff --git a/day-6/Cargo.toml b/day-6/Cargo.toml new file mode 100644 index 0000000..a253da5 --- /dev/null +++ b/day-6/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "day-6" +version = "0.1.0" +authors = ["Tristan Daniƫl Maat "] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +indoc = "0.3" diff --git a/day-6/input b/day-6/input new file mode 100644 index 0000000..9745c0b --- /dev/null +++ b/day-6/input @@ -0,0 +1,2087 @@ +v +vx +v +vx +nclmbv + +odgpnwqxhbits +pqwsnxihogdbt +pogiwxdhqbsnt + +q +o + +apulnqresohvktxcymzibdwg +sigdvakmlyxhetopnubwzrqc +iushndtclbeyowxpqmkgzavr + +ow +wo + +phegq +eqgph +hgpque + +xispjzq +sqkzcupi +ikspqyzue + +hgfesyvn +dnsvtkhglea +heygnqbcvs + +qmrpy +pmrck +vcprum +mrkcp +mrp + +kgjx +jghk +kjgu +enlgdwzqkjr +vjgk + +ungsdozkphlxy +nbkgzaifsovjpdt +geoskuyznpcd + +qw +qw + +x +r +sl +v +s + +kxcn +kxn +wxtkn +xkcn +xkn + +peionmzqyda +apdinomqzey +npmqoiedzay +dmpzoyqiane + +gpaedw +mwda +daw +awbd + +fyxeptlrmisjhdzquv +xfqydzruvmjepsilth +sipulvdzmftqeyhrxj + +kzofrcamenxyvwgpq +zqkrapxwomvycgnef +ywxvpazgcenrqkfmo +kgcvezmfqwrpnxaoy + +zhf +zegfhd +fhz +hfz + +iqspn +bytmd +sq +gwx + +begosk +gnbskz +sgkb + +ok +ek +ek +k + +hbucsatqvdryfojxlz +tufzxjvbrwasemg + +d +ef +k + +p +mrp + +kuywroetvjnf +wjvtkreufyn +frkyjwevntu +frtewnkjvuy + +iu +wzi +axbcgpldyi +seoiz + +ekjmbsuwglftpvya +esmwuftgpvyjalkb +vflbtyekmjupasgw +tepmwgksulybavjf +psawvbtgjfelmyuk + +jsmoydnvkiql +lqdojsvnik + +ayrtxivjlpeuzohnk +whjitnkfyealoguxprzc +bzjiruohtlakxnedypm +pmyxeizqjhkntoarul + +vnrcwouidfb +bufrwnociv +unrvefbcwo +cvnswubfro + +hmnoazwvtcrigqsujldpk +qeflzdwyongvtjishpacumr + +ytwpgkvceaolhrz +agyepkhwlzvctr +yvpkwcgerzhtaq +pcaeygktzwhrv +rgvpkwtylzhcea + +io +oi +io +ito + +ckmfawyb +glvfiymobadc +jnsfbmapcy +jfysmathnbc + +uxbfdygqwpom +sxmuwbdporyvqh +rbuqmwxydpo +ncpuyowqildjxebmk +wxuysoqhvbampd + +keo +oz +jdorxbia +lo +ok + +zk +zco + +bhwmscnrqeou +rlqenzswohbmu + +synmfzljkdebq +cmdyzlfekjbns +nkgzsmvlydpjobfute +lsfjkmnzdeby + +xshlzwcndtjefi +wcnljfditsexzh +ehtsjwidflcznx + +zry +vyqz + +owfcybsdipnqlthavu +psdiqfhwctrzvaybon +ybmpdciqhvtsfawon +givjcetkhwbdyponfsaq +cvotsnhqfywplidab + +cibwptjnu +ncruhi +hnuic + +apzjqbdlwyicfgxv +apxodvwlzyfbgqcij +pcdxjvzwqfliyagb +rixjaclsdpvyzgwqmbfe + +timpsox +poxsm + +fres +refs +fersq + +w +z +r +w +r + +xz +x +x +x + +ciyhkpjswqvxz +xyskvphmowjzcia +kywsxihpc +wtpnflcsekhbgxud + +qrtweigjlbucfxnkos +iwlbgmnosuxfetkrqc +sfbwxcotierqukldn +euroqfdxywclsitkbn +qelfbarchnwuxtsiok + +gj +woh +g +jr + +lpcdqf +qdfupwzcl +dpcqgtl + +zlnkeyroq +rtyoleqnkz +leykztqnor +ahoukcelrxjqynpz + +twxjdbuhclzgnop +fgeqkcbvziwtludop + +ylukhwtcf +aikdrxfov + +ucbklojiyxmz +ulkjco +kroljuch + +rfhyj +fhy + +cmtedvxioy +infmacweshtuo +tpoimecz + +kylduhw +yublkhd +kdulyh +dyuhlrk +zhfgkudly + +laoemdcgpyhtnb +ygclebodtmpnha +zomgnqpalhebxwtcd + +bmogrnztvyil +vlotrzngbmiy +lvyogrzbimtn + +zjcgheblotdramsn +mlgbshrzotcnjawd +otgsjdnmbrchlza +dbazlpfkhgtmsvocnjqr +sgrazcjondmlhbt + +ryhifaxpemsgcdubvtjzwnol +bduiojqhcsvlyrxefntpgwma +pvebfwitculrgyjshkdxmaon + +lqmopgwbesjhk +mgbkhqejlswop +wqklaeogsdxhfbmjp +sjgphokmqewlb +kesrghbmpjlowq + +tu +rp +r +rgh + +tfeyhjbnpaqwz +rxuefvgiaybzqth + +pwx +lk +iahyv +jr +p + +ezsghqtdnjbfox +dsucq +sduqp +cusvdqy +dslwqm + +dm +gf +g +xtg + +mfihn +mhyifot + +iabeswqrzlcxvkpmtnug +qexctgrkwbpusazinmv +riztmgqsewunxbapkcvj +avbuxqizmrkeswtpncg + +ozrwipdmgajlkfuxcnhtyveqs +fntcigalzdxmyuesjkqwo +dtfyeqklgjmwxunosizca +efclkowaujqzigbtymdxsn + +jkiupmatwxqhdrs +midjhwutq +dmhujzqwyit +dwuqhymtji + +ziqfh +hnboqe +qhktzdfp + +qohbywgtlucajf +ltahuywfjbmc + +arfpqdcbtnw +kfzonycewxbghvr + +tdxqelwnu +luenxdtqw +udlteqxnw +wxendqlut + +pvkrgaushqidfmnjz +eajzrkhndfitsqvmwugyp +sgohxqcvrzunapjfdmki +vinodpkazgfrmcushjq +jmufirnszpdqoahgkv + +uvcmgfrk +fugmrvck +kfuvrmcg +cmrfgkuv +kcvumfgr + +kmrb +krbm +rkb +bekrt +rbmk + +mzbrfsnxgjpywavcohuqlkitde +xpekistdzlrgmcawnvuqfohjby + +vrjew +rvj + +qlefnd +fdleo +pxcehwdfy + +amftbpvo + +ljcyn +cynosjum +jync +yrqbwjzc +jcy + +tmdcuk +ckudm +mucdk +cdkum + +icsvhmefaztoxkgndq +sbyqivkrdplwjemou + +jtrhafpkbwzdox +hbrwpzajokfx +jbkfaphxzcrwon + +bqg +qgb +bgq +qbg +qgb + +ljte +jle + +tvhjx +hvjwxrt +vtjxh +dtjvhx +vjxht + +zsdejcrvab +kbjzrscaedv + +oehivmku +igfhuxozy + +x +xs +x +x +x + +klqnrzftv +iqgfaupt +fdqgswyjt + +opjeslcx +psohecjxl +yxelsjoc +lescojvx +molnextcsj + +sf +cps +fos + +crxbjzkivydsgfpehmq +wnhfgljeptzrmikcy + +bghydvqxicsfunlzpart +rsyugqcxtvdzanpblihf + +v +gnvw +lv +v +lv + +mpzvdjqhxnuocr +chidrnuvxmkjqpt +suhdxgvbcnrpmj + +ewpfugobznrqydsj +ivgxtjludcm + +enytuvzoqmljfwd +satbgwcrndzyk + +fuzl +ful +lu +lpuxy + +qrhltkesazpmo +puaedmzsqhot + +vcktz +zqtjsbuiaomwf +ygzkthx + +zt +tdz + +fvpjlcarqdukio +luotiqzkjfrwahcdvm +rcykufoadqxilvj + +kfpuwxi +wpfxuik + +xjzpf +cyqsouwf +xzf +zf +bifpj + +q +cw +n +nu +q + +lscdtzvhajkqpm +vdpklhqscm +pvcdqskljh +hcjdqklsyvp +eqshcdklvp + +muyldxobakfq +ecjvfm + +jkas +ws +s +ws + +qbjzcolnuy +jyulobzncq +izqlnycoubj + +yvsoztedn +eotvydz +yzetodv +edvoyczt + +tcfqkxrib +fozbtnlwucq +qvagfdebtc +qcpftbk + +amlcyk +acempy +aymcv +cayml + +gsybwf +ybsfgw +bsgywf +bfwygs +fsygbw + +hypxicwobt +pciytbxwh +xhycspitbw +pcibytrhxw +yckhxtebwpi + +olneqtcpzfiahbj +oitbqejcahpnfmzl +bpnjyhfkqmlczteoai +hlpjefoaqznbtci +jdwtzsfcviaqnobhpxel + +mkflqourwyh +kqmylohfu +lyohqumfk +fyhukomplq + +cfegzaprw +prvbgiymj + +besuka +hsnkua +slaguxky + +smwuovdpnjfyl +mcjvguors +qjvsmiou +abotmkxujvs +uhmoqsvje + +udrmcxqay +dqyhumca +mfwcujskglbedqt + +xewpyrsjzktgbaochuni +xjaohuwligysztekpnc +tfghodxyjsnapmquwcziekv + +fxypwlo +wpsxleyfo +ylmpxfzwo + +ok +rspbkt +mauyxcw +rqdkz + +fsehripoyjawt +styheviwfrn + +onxrvplyuzqcj +vlzuyrcpxoqjn +nuoqyrzjcpvxl +ljyuoqvnzprcx + +o +ac +c +c + +hwxmesjuzo +hylvoxzpfbntsr +shoquzx + +pidfxg +igrxm + +gshkfbcujpyztoevxdlmaw +kzvmejbygdpaxufhlcotws +hfgamkstbwjoyxlczupevd + +p +p +ltf + +iufdzosnagkhtw +dzkhlgvsitucoa +adtgzokhsviuc + +jywe +wy +yw +wzy +yw + +ghvadykiscnfxo +noxckgivyhdaf +gfxmtodbwvnkhipaqy + +ifsp +xnivluaq +fioe +wisydc +siw + +jxbmclnevwztqug +keptqcrmzufglhi +tleqgyvjbumzdc +xzdmslqcutge + +ogdxpnjbti +ipgnotx +ipehgonkcxrtfa +ntdiygpox + +wxhcjtredknifvulymp +vgksmwqzctybidjofha + +lxmficysbt +jslmrn + +pcoxigrdtkul +sjmhtbxulyord +uxlcpdktoarv + +crgundohktjfasebzvxl +gdsvcufrnljazotkxehb +onbgcjfeirxkhzvudtsla +njcheafbokgzvsxrudlt +ekgvfruchstjldoxzabn + +wmkivpgfqdrsl +wmcjvofkhnz +kfwbuvam +jtmwhfkvz + +thy +hy +yhe +yh +dqbyh + +xtbhkovsjcga +xqkoeavjsch +xacvkjhds +mcjuwskavnrixyh + +lhfwqr +ypkruwqs +xcgdwmj + +eyiwrundqsflgcavxk +fejmwtyulodkhrzbp + +yvz +expa + +aohj +ejoai +ldypfnejoa +dcxpjoatv + +vuinj +prv +v +vlr + +sqpdmrnlwa +nlgasrpqomd +padlqsmrn + +r +pjd +d +azbhs + +hfotieypnlwdkjzv +jlfveimtdckongwzpy + +af +zaf +afn +abf + +csjx +scrk +ucws +csj +sjc + +juwtder +dtjrwe +werjdt +djreywut +rceoqjwdt + +nazufjeomxpkc +xmeopajcunkzf +pfcuazejknmxo +nkzceomfapxju + +epiykxforjz +fylzbxjeoipg +ahfyxvpmsujiedzon +eoyxcqwpikjzfg + +umfrlqhakzdn +mshjfdkqungrzv + +opxjdgemsvailruzfbcq +ozmgbdirxelyfsqpjvuc +iqbucpflxsvzdoetjrm +ysiqolmberzvjnctdxgufp +bxfemdhcukplzrijsqvo + +yocg +g +uqg +rzy +vjbmw + +vljzumo +ujzvmo +vujomz +vjzomu +zmjuov + +srwagukx +ahjroqmxy + +cgkj +jcgknvs +jgkyc +kcjgy +jrgck + +ugcwvx +gfuzaxw + +n +o +n +n +n + +vsmd +mcdvbs +cdmxy +tadr + +znsokugwejfylica +iwpnfyolqzkcuaegdsj + +azuver +remzau +arezu +zerau + +wevbmlq +bwalcodevx +ewtuxlbv +zivypeswlb +ebwvaln + +qjrdgxmc +hrcozqdxj + +mpcogjzyrhisuxlv +mskpazxdfvqc + +xtzyl +lxyt +xytl +xlyt +oxslyt + +jrteqswkcazlbfhog +tsqafcbgrelzokhjw + +fjqlibpwukcoznavyrtd +bzdtupklrqivanwyojfc +lvjarpkyubndzqiwoftc +bdrcniwvktylpajoqzuf +uycprvalqdiwonbjztkf + +lwga +dgswz +zgwy +nwugcrik +gwsy + +gwmvxakicou +avugcmowixk +ckxugomwvia +ukwacxogmiv +xiwavcgmkou + +znvgeymhb +rztconyiq +lwzayn +jswnuzyk +fnwuxlypz + +etkdwlgscmzyuafvhbo +vhctfgkmwouaylesbzd +vfcetldzsyobghmuwka +tsgzmkufeajlvwcyodbh +gazdhmkotswlfuvbcey + +zdsjweg +sezjgd +dsgzei + +zi +z + +tbg +fbtg + +g +g +g +g + +rid +jvi +inxo +id + +dbrjtfupcyvzlqmwei +zqbwfmljvcdirtyepu + +jmhubvclsdprw +cpswbmldjrveu +rpbsvucmdfjlw + +qk +ekniz + +kvlmhegzcryd +zrlmdgvefyhc +zhgvrqueymdca +remdfyhzcgv + +zxhiaqs +hxiqsa + +sumrbd +qgrbuw +ubqgr + +dkmqsebjznylwucxot +ewyqhjrlpcfotbis + +ti +kxi + +dvgmlyepfnhscui +isbvmudynplf +nzqldwmfyuvtpi +finlydpourvme +dulnypvsrafmik + +zemctnsralu +trnaelzmsuc +azrstumnecl +mltrceasnuz +rtazlucenms + +aydgxnwehomujpv +nedjuaxhopwvmg +dvgwhfojpanmuxe +wjaenpdvmohugx +vanuomdxjehgwp + +xchjblnwmogv +coxlngbwjmhv +mjbwoclgxvnh + +br +rohb + +knpclsvozb +slcvbznk +klcbnvzs +lsvbkncz + +cehpgtzmawkjndufrlixb +anrtxfdbhiwmcjzplkeug +rkmwtcunzxhjpgbafdeil + +rqlstcwxkmoz +thsvxzkueymrlqw +rqlskomwzpaxt +wcxrzmptqkls + +tshv +hfzdlpij +hmces + +kfjmaedcoqltuwp +jrngliqdohsce +bgclzdhjqxyero + +urndaqxz +fyw +wzqua +ehglomjvbk + +guhfvqlnkydpiz +ljgyoiqarzksuwet + +yutebcorzh +slxcdkqnhjga + +fivxqukh +kixqzvu +vqxuki +xnpiuqvk +kvqfxudie + +rpsfdkmc +cdefrksmp +khmsfrdpc +pdmkrcfs + +hwn +whn + +rxhbzyedclofgwmuktsp +xlmozsbgkcfeyurthdw +psgtkcfazdwomblhyerxu +ytvfsxukgwmlrzdhobec + +nrvyx +vytxn +xyvn +nxvy +xnyv + +qct +cqt +tcq + +y +dy +lcwtunshbmy +fy +ry + +cnboedgyxatrk +ktdbeocgnay +wbkgtecnyahmodq +nxbtgzcsyeukrado +ydagcekbfont + +jytulh +yhtlz +fwtrkhly +bylht + +huigqrok +ikhrong +bighkwor +kgxrhosi + +zbkrpelxtsohdaw +ewzkvcxrdtboas +rabkdwoxyneszt +axhkbzrwdteos +rtbowkelsxzad + +aonplewqryh +euyqrfncsovkld +byalnwiezroq +enobxrlqy +pmgzeryonql + +akxpsmecuj +kfgsexjm +oxqfeskjm +yervixmdktlshbj + +r +r +r +r +r + +rdghefnubpzkma +dhubafromtpekzgn +knmhfjduebpgraz +zpekdbfamrnihug + +ybcgsmlwhovidfezp +omfpzqugycwrhbs + +x +x + +vjahspyncxzmie +zmpu +krpmzog +tfpmkz + +morafxw +xyckafoqwjm +ialpowmf +xhrsmwokbfjazu +anmfowdbq + +gdpblscxazjrmikoyth +exrolqfahdbymcwpksjt +gtmadncysrlhpojvxkib + +nxdilkwregfbaoqp +exnjrbsifwypkqovag +fgrotinqbwpkxae +flndzeoxkwgrcptibqa + +sidjln +mjslodni +ztdoxjnise +odnsehfjti +dnsyij + +qx +wmxtj +wxzmtucqy +godkvenhxpb +xrztj + +xofhvkjytqus +ytdqjkufimvx +uwyqntcvfpxkj + +rdtqukinob +wzufpcolmskynvteh + +vnab +kouvrfe +ljvcd +wqbdpvsy +bighvnmx + +frgsavwjel +fjlrwsaveg +afeljgrwsv +jlvsrewafg +kvfesjlwgra + +ygdszflehmwcnbopiatxju +jdnupgzmilsywaechoft + +da +rzfvailh +bhorq +ctgujpmsw + +ymbnzldsi +ltvsfm +mgcsl +emslgw + +taqecxvdypifblzgk +cekxfvgplrnqbty +vejogtfwqbyknlrpxc + +souwzdkcbqf +awzqgvbscukdpxn +bcszjdfkuimwq +sdbcuzqkw + +avrlf +kerlgmuahvc +wavfibznrol + +upnkam +xmjt +milex + +rxotufwczkpvia +pajkvhwtme +gpnektwljasv +pknaqwtvey +wpadktnlvjb + +kpfj +syurwad +asyvld + +p +bpz +po + +s +u +s + +ksvbeno +uyfivq +kbjodvh +czptrmawg + +xtiqze +xtisdz + +pylbdvkncjurmgh +yhbdoltvrpiknmjucg +vbmlhynrcugjpdk + +byoavnixtlzepjds +sapxunqeizdvblyho +qvlmeoisanzyhdxpb + +ifykcw +iyckw + +u +p +s +s + +f +f +f +f + +fvbjxaiklos +ufqnvcgxikdpalobt +bixlarfkvo + +ygpsxce +cpdsfygaxueb +ycgsxep +epcxsgty +pctxesgy + +meawzoqnidgh +hodmagqnzew +mwhzndaqgjoe +cdhseoqauwngzmx +oawmeqfdnhzg + +yrlvejxocsh +hvjrsmloyne +nsrvyojlhe + +zhufxvrkcdmwqlsa +lergvwdqnaosxtzchukbj + +xbvyt +ybvndgxt +gzxtonyb +xbcuwtyp + +creoxajkgvq +vgljkrexacwmhq + +wckjovuftgmb +boktfjuvgmwc + +cguaojyvre +ohiknuqags +lcazjyguor + +inhyfk +kify + +uhtqci +tfoqacim +srvcjytkqgx +hqctz +qmctahizn + +vekplqxuhrm +kmeuprlvqxh +vhlrkmpxuqe + +at +tagexyi +mpt +yxta + +uezmyjqvbgspirlc +fydbljgwmzxquecop +zptrgeybcqmluj +pelzjcugymtbvq + +fakguojpbsic +ubcfgyjakpiso +bliusctfvkampjog +fybsicjawkupog + +kmxerqlautij +zxidayte + +imbngcehtvs +oipfmkrqusnwxdzyl +imasjvn + +pek +e +ei +ep +ex + +yuw +uyw +wdysu + +omikta +zjvatmw +txsma +cm +lndgqmry + +cwazbkolvys +liyoveacbswj +siwokbavleyc +rocsyndufablvwx +aylbvcojesw + +nazfjsrouhgtv +zgsprothnufav + +ptmshxwqk +sebqodwi +euqsw +zwousq + +uqltjsikhpvefdawycbzg +plyhvtieubakzswqcfjgd +wehjvikyfpcsgaqtlbuzd +sfibzvquyljekgthpwcda +cgbtvdolizaeqypfksxjuhw + +izeqstg +sgiqzet + +fqbmpoxscydhrtljzga +cfqodxevmajhbrplzt +oecfrzvbpdaqhtjlxm +adfbxrmqlctzpjho + +dsmewbhpvrfuknj +opcvhwtrqkue +rwvkguhpzoe +vxpghreuiwqk + +fjzi +ftmizn + +xumjz +ujxymg +zumjx +ujmx + +n +l +l +x + +ghwfslriojz +rfzliwoe +flrziobw +ifcpozlrw + +smvfnglxaeczqwukojhbi +uieagsoqbhvlmjcfxwknz +nxoacfwemhijsgqvzbkul +qanmsiwvflcjbxzoeugkh + +pzciwneljbghoufdvymtqar +exlhrjvkpnmdoqbtzusiwcgf + +uxjwpobgcflndqairke +oktwumrzjlyedagxbinsfp + +oibhmyeguqkxjrcpawzfvds +vhsauyxdrobwcjmkzqepgif +gxhiwozfkbsecamrypudvjq +mxywofehvsczapkbuidqjgr +xsmvybwqdgrzeucfahpojik + +gdtlkuomn +ytkueoglh + +xgimja +gjxibma +mjbagix +xaiojmg +mgjaxi + +sgnfdiz +dto + +yhkvqrzw +hyknjrzvq +xtrhdsvkzoqy +ykqvzhr +zkqyhanegrv + +tzqrhavysuodmjp +abvpofyzhmrjqdt +yzopriuqnvmtahjd +atmryjpzhovqgd + +cyljrwofasq +afoqswrjclu +carljswfkoq +ljwsfocqyra +xjolqcwfars + +r +o +ak +xdje + +lfyjxpoeau +yhlgcftszpr +pkylfomw + +lunijqekwg +vafgdsjqeklniw +yeglwqkjin +leqgjkniyw + +mpvlijnfbz +jzmfbplnvih +jqdlpvbmnzif + +tk +tk +qkst +kt +tk + +mdowpcnxgbvuytqezljsk +tbnzcduipewvxlkqrsmjyga + +ilumzjpqotcv +fgtmowyx +gdsotkrm + +yncslevbgrqmizwu +brclynqgzvuewisfm +lgbzcesuvqnrwmyi + +bjmzopcdiqlyueh +olyupebiqcmzjhd + +eubsjrvwmyinzkaqdgcf +icqzjksbyregauvfdwnm +jugdnbsczwqfarvkyiem +benyrimfwzaqvukdscjg +ndcuvaziekbwyjrqgsfm + +g +c +c + +gvyfqupnxtswb +uvtykbjxgifcqz +lhvobuxgqfetmy + +dpzgaulb +plqugbrdmac + +htr +kgrt +rt +tr +trg + +o +qv +lr +m +l + +qotxnerijpfbkcagylh +nilhcfrpkjgboxaqey +ognqxipefrbjhlkacy +kojtilqxyrhbpancgfe +qjilgekcfsnhxapomrby + +fes +feoijn +ef +ef +ef + +dlzga +tlsidg +gdl +lpdgh + +onysxwkqlcgdemhup +mzlscwgkdnouexyp +kzdubeoyslgnpcxm +dymulpowksnegxc +kpusvxldgyaonemrci + +xh +e + +utbirhymae +yzehmoukq + +ijvulcmbrgkyxao +uvrajglcbomkxiy + +xo +zo +o +xo +o + +mbghatcenlifqjdkp +ejscikpgvtomhnxqzf + +stpvo +cjvpthsl +spvdnyrt +qvypftsx + +obrxaqyudvinmk +qlimnvosubahydgkecrx +yrftzoxkjqvbaidm +kvqaxdmboirwy + +dxj +xdj +jxd +jxd +djx + +hfjeucmkrvnwxs +nxujekrqmsbofhc + +ezarol +lebz +bzel + +jgmzcl +jlzcmg +cmlzjg +jmclzg +gmcjzl + +o +u + +bdfqljiuacptzvgrxoe +pauvztlihdqrjofgx +xtrjvzuaipfldgoq +jzrdtxqlwiavungfpo + +cjurgpeyvlzhafx +aurhsfbvpeyxgjzc +gzvhejlkpxyfocura + +rvyfbicazduolwtgqk +qklnrgyaofdzvciwut + +qsw +qs + +nrfgxpujobhk +rxmpnokdgbjfi +lxbngkrfyjvcoz + +e +e +zegkx +e +e + +kon +k +k + +ekvi +iekv +ekvi +ivek + +jfbyxwhrne +nxjhrfbdwy +bewhryfjtnx +mfhoxyjbrsnw + +bn +n +sxv +d + +egrzknhbxfvqtdcu +edhrioxvjgnzbf + +yjoskmhw +kdtqfehazbyu + +zq +zq +qz +uqz + +ilbpcz +ibcqplz +gczbpil + +nikychwgab +caibgwklndy +ckbenqwuafyg + +qubikjdz +jkiuzdb + +gwmavrpfsdnkyizuelt +yuqnvjmlogpizcfetx + +tnsf +thnfs +tfsn +sntf +nstf + +vflagunhs +aiwvlhjfsunxg +ulvhgfsna + +yajtfdwh +hzdpalftjb + +nazpqismug +pznuismgq +mgiqnupwsz +mgptzusniq +boifzpmsuqgn + +ohu +ht +hpygo +ijkdfhcb +uhno + +kfzmrhyjvw +hzgxpjbkwvyr +zykmfrvwshj + +yqsezgcojbw +zjsgcoeqby +jgfsbozqyec +czsgoyfbjqe + +fjywktd +yjktfwd + +nwvrodtpqy +xtrvnosihzgq + +gdwcmlxiqtynsjozapeur +xwlgsjatqzycnodprmue +adxtgqujrcopnlwsmezy + +snep +shwz + +unvpgc +guncvp + +suctpbxogra +kcxvgteayu +ztgxuacy + +pewbhlvjtg +omskldnz +iafryucxq + +zoucjefxpdta +xbfijrelpucsot +ktoexjpcauf +jtezoxkpfhcduw + +xiaszncr +asxnircz +xzncrsai +rixseuzanc +nzaicrsx + +owtvxqcizrapl +alqxivcprzowt + +ltrhdykufvwex +ekxvfldwuhrt +ervktduwlhfjax + +ylvgpjthiex +snmbgjfzduxqearikc + +eml +bkhyl +rzsoitwqn +dacupjev +fldc + +uqigoj +ojui + +zgbsumeycaxvontwdkij +jbtelqcxnumsoakiwyvg +waseyvijugnkobptcmx +atesbkmjuhcvfngxywoi + +pc +pc +ikyp + +xtgvlenosarwubmfihz +txganvweourhbqslfmiz +lientrsuwghobfmvxaz +taluorneizhswmbxgvf +zginuholscexmftrbwva + +xjkv +xtouw +tywx +oxwt + +zk +cz +bz + +qcp +qpc + +ogptyeunzsqmarjc +jrvlopzynes +xoszpnjryle +zbrnypsoej + +nuigyflbxs +yxunspgj +vnuscztymqowgxr +ixnyshgu + +pdn +cyskxdp + +ewlkgbdxqtiz +eqgxitldbzkw +kbdexzgitwql + +c +p +t +v +gqh + +uvigbjqk +ibvugq +vbuiqg + +wzdca +dzawc +cawzyd + +mfaigwlu +pygxjmufwal +ugfwlam +glmafuw + +bewfkxsvl +yxdqnmaturov + +fdrbt +mxjnfdqpc +wdltfo +adwletfr + +t +pgo +e +tiabc + +zbthk +zbkhatr +zbhtk + +flxwhbzkei +lwkhxfezbi +xelfwbzhik +bhzefxkliw +klizhwbfxe + +btmwkoqs +bstomkqw +wskomtbqi +kswtbmqo +kqbswotm + +kdfbzj +bfdzjm + +bf +ef +f +fut +bf + +bvl +lvu + +kezwynmfrgahlbqsjtdxiovpu +wmaukoqsldvheztxrgjpifbny +qgkrwvaiznhpmtlxjubesdoyf +osverdamnxjufcybpkztqighwl + +nza +anz + +wfjsdaq +iwlrou +ykwftq + +zgtuvqxmljwyaifcbp +pcgytlqjvbaxwzimf +cmqzwaljvbufyigptx +sxgvcbweymiflqajtkpz +fhgmjpwclzibtvaqxy + +rohqjmnvlsdaigywbxe +xmhiarjdogqwbvnlsey + +jhz +jhz +jzh + +oemyvhgznpblsq +hpsvzycebqlmng +elhnwqdpbsgzyvm +cenomgyzhqlsbvp + +gdnc +wncd + +tnlprwbcsaygzqxuoev +rxqdasecgwbzmfvntpl + +jtucglizkohrafs +ebjhogu +hdugoj + +ncyvqk +oulfaxqnerid +ptmsynbvkwq + +mxihwyzetlbnkpfs +ksqwhxtzbenfpim +nqbtxwsepfmkih +khixywsmbnetpfl +peikctmafswhnbx + +phylqxrdtg +yxtapqni +nkiwytuveqxp + +lhqrfys +sqdfly +ysfhlq +sylfq + +sqpjuobilhmtvrxaz +kuwgncfdv + +dqzke +qezkd +kqezd +zkqed +kdqez + +lio +iol +loi +lio +oil + +hvpwi +rhvp +fpysmvd +tpvrl +vph + +idjeoxvyqaufgpnlc +xnplcqjvdyigsaef + +y +qw + +rhb +fpqsiadrjkl + +hinvdck +kvcahnid +fhcupntkvdqijmy +dvnchik +aivcnhxkd + +xqugmnktofslbpevzd +yaqztjnicrwd + +biadvoeznswx +iaxszcdwboj +isbdkxzwoanve +gikqxzorsadfwb +asozrwidqxvb + +bvotgwrxe +xbhryeov +ojrvxebi +vxeorb + +fb +rqwl +qlrjyfp +nkhgmov + +zexjvfbwro +wzvxorfjbe +vorwzexbjtf +xeovwfjbzr + +owfmx +uxomf +mfo +cfkmo + +atwsbvcn +mijkzngueoy + +twqprciyaxkb +barckwiptqyx +iabyqwtcrkxp +rqbkipctxywa + +vmhzjek +tx +aix +dsa + +byzxqpgureth +gbxryhptqiezuc +lqrzjwythegxubp +hqruytzegbxp +tepughsrqzybx + +hwydxbeflai +yhewcfbaixd +yhwadxfeib + +hi +h +h +h + +mhket +mtkh + +loacixzmfy +fmxlzaoyci +ylifaxopczm +czyafoxmli + +ymrfxiwbse +ihpqjuaczd + +ealixkwz +gocmqyfthp + +gedjwnt +wtdezgn +hgcuwrtnped +zjngtdlexw + +jk +jk +kj +jk +jk + +gkxldasfhqncbiyu +hnpfbycsgqkuldex +hquxfksigydlcnab +cxauqgdiyfbnkshl + +niahryvlxbekt +dyhknvbaleirtx +tknljyvrihbzxe +seyxknvihrcbtl +bxrhukldytvneiw + +vuq +cfawvlt +rhnvzu + +wxlhvnmispbot +whvbcxmolntips +snhtmbpwifulxov +itswhupmncvolbx +rhtlsdpiwonbkqvxm + +ojmyc +kfzuehvirps + +mk +km +km + +fjyx +jitrevpfy +yjs +jyxmiect +dykgjnzbl + +rbwpjflnoegkqt +hwxceyimsdzntvu + +golf +fzgol +dlxfomg +lfozg +floag + +dfbmcyi +yvzpkrbc +icybu + +mcbditlrfgeaoh +camdhrfbvoglei +riagefbmclvokqz +dbfogjmeacrpl +lwuogecanfxsbrmy + +lgsnwuockhmpxibedqzaf +cvmiepdsubkgwzhf +bsvipdjwcfkmezugh +wgfzicsmubpdkeh + +iyeorgvpmutnhqcwxj +jqoguadpnmrk +nmpquzglaorsj + +apjqhruongvztmiywecl +padwbieyshonfrtxqcukzglv +yolrhezqicgpmvtaunw +mljzahrwcpqygvonuite + +szhjetf +sdtozreuhmfp + +f +f +mf +f + +gnjqcad +idlhjay +rejbwamoud +danxj +zjkdia + +lupiwyqntjgekvsr +gwqupjykitrlnsbo + +ojcxmuqsrhyv +lgcovdyhnifsp + +wphvcu +lznsm + +wpq +qpw +wqp +pwq +fqwhp + +nyzx +ubpx +xwi +wtxhe + +vkujyxtido +tvouidyjxk +vidkjuoxty +uxtoivdkjy +yvukijdoxt + +fpuboyiwdktvc +hsqnzuagr + +swabt +mwsb +sbwm +bws + +idlshcnf +ficnd +tdfcin +nicdf + +ajodwgmsy +wmjvoygd +ojdwmyg +dovgwjmy + +yemtzisjpxchanuovwdkr +evxtomkyhrupwsnizac +ytevcsimkwrnzoauhpx + +whley +dhyetlqf + +fqx +xf +bfxz + +ipwvb +vdnb +rcvnf +chvr +xjtvyez + +sdpuoewx +wfqrphkdelosbvgyum +pudzioesnw +idatsupewo + +knfheau +kanehuf +unekfa +klcsnemaufy + +yhuvigcrp +rivgypcuh +urphgvciy +iyhrcvupg +vuphryicg + +flozkyvhnwxr +fvpsybhlwrz +hzqvmfgrl +irholckaveszf + +gypwufz +agspwqmuyz +yogwpzu + +c +oc diff --git a/day-6/src/main.rs b/day-6/src/main.rs new file mode 100644 index 0000000..9035577 --- /dev/null +++ b/day-6/src/main.rs @@ -0,0 +1,137 @@ +use std::collections::HashSet; +use std::fs; + +fn main() -> Result<(), Box> { + let input = fs::read_to_string("input")?; + + // Part 1 + let groups = parse_groups(&input)?; + println!("{}", count_answers(&groups)); + + // Part 2 + let groups = parse_group_individuals(&input)?; + println!("{}", count_individual_answers(&groups)); + + Ok(()) +} + +fn parse_groups(input: &str) -> Result>, String> { + input + .split("\n\n") + .map(|group| { + group + .chars() + .filter(|c| *c != '\n') + .map(|c| { + if c.is_alphabetic() { + Ok(c) + } else { + Err(format!("Invalid answer: {}", c)) + } + }) + .collect() + }) + .collect() +} + +fn count_answers(groups: &Vec>) -> usize { + groups.iter().map(|group| group.iter().count()).sum() +} + +fn parse_group_individuals(input: &str) -> Result>>, String> { + input + .split("\n\n") + .map(|group| { + group + .lines() + .map(|individual| { + individual + .chars() + .map(|c| { + if c.is_alphabetic() { + Ok(c) + } else { + Err(format!("Invalid answer: {}", c)) + } + }) + .collect() + }) + .collect() + }) + .collect() +} + +fn count_individual_answers(groups: &Vec>>) -> usize { + groups + .iter() + .map(|group| { + let mut iter = group.into_iter().cloned(); + let first = iter.next().expect("Must have at least one element"); + + iter.fold(first, |cumulative, entry| { + cumulative.intersection(&entry).copied().collect() + }) + .len() + }) + .sum() +} + +#[cfg(test)] +mod tests { + use super::*; + use indoc::indoc; + + #[test] + fn test_simple() -> Result<(), Box> { + let input = indoc!( + "abc + + a + b + c + + ab + ac + + a + a + a + a + + b + " + ); + + let groups = parse_groups(input)?; + let counts = count_answers(&groups); + assert_eq!(counts, 11); + Ok(()) + } + + #[test] + fn test_simple2() -> Result<(), Box> { + let input = indoc!( + "abc + + a + b + c + + ab + ac + + a + a + a + a + + b + " + ); + + let groups = parse_group_individuals(input)?; + let counts = count_individual_answers(&groups); + assert_eq!(counts, 6); + Ok(()) + } +}