diff options
author | Julien Dessaux | 2023-03-13 21:36:59 +0100 |
---|---|---|
committer | Julien Dessaux | 2023-03-13 21:36:59 +0100 |
commit | 9c4275d2181f72aa672e3c8cbe2336eb34c19a25 (patch) | |
tree | b45382b88080c82daf9512a131ee29bc810c81f4 /2020 | |
parent | 2020-05 in haskell (diff) | |
download | advent-of-code-9c4275d2181f72aa672e3c8cbe2336eb34c19a25.tar.gz advent-of-code-9c4275d2181f72aa672e3c8cbe2336eb34c19a25.tar.bz2 advent-of-code-9c4275d2181f72aa672e3c8cbe2336eb34c19a25.zip |
2020-06 in haskell
Diffstat (limited to '2020')
-rw-r--r-- | 2020/06-Custom_Customs/example | 15 | ||||
-rw-r--r-- | 2020/06-Custom_Customs/first.hs | 26 | ||||
-rw-r--r-- | 2020/06-Custom_Customs/input | 2179 | ||||
-rw-r--r-- | 2020/06-Custom_Customs/second.hs | 25 |
4 files changed, 2245 insertions, 0 deletions
diff --git a/2020/06-Custom_Customs/example b/2020/06-Custom_Customs/example new file mode 100644 index 0000000..0f5b3bc --- /dev/null +++ b/2020/06-Custom_Customs/example @@ -0,0 +1,15 @@ +abc + +a +b +c + +ab +ac + +a +a +a +a + +b diff --git a/2020/06-Custom_Customs/first.hs b/2020/06-Custom_Customs/first.hs new file mode 100644 index 0000000..883d6e4 --- /dev/null +++ b/2020/06-Custom_Customs/first.hs @@ -0,0 +1,26 @@ +-- requires cabal install --lib split Unique +module Main (main) where + +import Control.Monad (void, when) +import Data.List.Split (splitOn) +import Data.List.Unique (sortUniq) +import Data.Monoid (mconcat) +import System.Exit (die) + +exampleExpectedOutput = 11 + +parseInput :: String -> IO [String] +parseInput filename = do + input <- readFile filename + return $ map (sortUniq . mconcat . lines) $ splitOn "\n\n" input + +compute :: [String] -> Int +compute = sum . map length + +main :: IO () +main = do + example <- parseInput "example" + let exampleOutput = compute example + when (exampleOutput /= exampleExpectedOutput) (die $ "example failed: got " ++ show exampleOutput ++ " instead of " ++ show exampleExpectedOutput) + input <- parseInput "input" + print $ compute input diff --git a/2020/06-Custom_Customs/input b/2020/06-Custom_Customs/input new file mode 100644 index 0000000..e04309e --- /dev/null +++ b/2020/06-Custom_Customs/input @@ -0,0 +1,2179 @@ +gwlcpbtxmiezd +xwlcpbtzimgdk +tbiwmpcgzdxo +ygzdbpjxncfwimt + +icb +xqhf + +mlpjsqwv +dvjqsipz +slqpvj + +waxcqvufpkeld +udkvxbjaglpq +gkxfpqvudhjl +uivpdozsnrqkxmtl + +tzhercs +cgxujw +dianpfvbk + +vwynik +obrut +gmbza +atm + +fvjnryuk +scihpabjgdxo + +kpeir +rikpe +rpiek + +inwtuxevsacyqg +cvteaqoylwknxfgui +ewqvugcxyntai + +xbsymjfvh +hmsbyvxj +vsyxmjhb + +atfckhz +wm +p +egdbwvl +jproey + +zgatorfjh +fbxogarc +sgvzafwj +feagpnqlyumdi +wfhvabg + +c +c +c +j +c + +egl +uel +le + +jcodp +jpdc +jmcpd + +nfz +zpiyn +nz +knhz + +rxl +dr + +g +suj +teo +cuzq +fzsw + +pqgdsbmuvechjxfz +auovygnkldfbwr + +jmos +msuj + +z +vb +wn + +dvyoixczmh +vmyxoczdi +ixydonzck +icwyeoxdz + +jafpextioch +pztsoxefcymrgjikhda +opecfhxjtuia +icuhjoaetpfx + +ipxyojqwegvu +bvhtiogwxjqdue +wongurjizvfekxmsqlac +xdvgoiquwej + +unzvtlbaxmfri +cfosmwtdpyziekhajgq + +lsipkqmohvztfcgb +cvqtblhmpfgsozk +mpvsbflqczkhgot + +wg +gw +wg +wg + +dpeyclxofhk +pgxheckmylod +xkpmcosuyeldh +yvoxhekgcpdl +lrhndwaoekycpx + +hva +ah +hat +ha + +zfqj +zjyqf +qjfz +qjfz +qfzj + +fvoaxgj +xfoygja + +gehvyapz +gwpzyvahe +zhavpegy + +viursfc +vucfr +mxstvocyufr +gnflvqdzkcrwhupa + +yqdxh +yhqxd +yhqtdx +dyqhjzx + +rkp +orkph +ckpr + +ym +epytqgr +jvdmy + +dtkcjulsy +tujysdckl + +mhgavu +ghvu +uvhg + +klqxbejfmgtrausdpy +mjayepflubdksgqtxr +jmakegrybfxutspldq +tpdyneqlmrkajxusgfb + +vlmi +lxhz + +bpv +e +mu +kme + +cnxwtbigkedzsyjr +ihsngtewzjukxcrd +cegsxnwydzitkuj +vpdlnsiazkejgcwxto +wizfnsgqtxekdjrc + +pojbrzvhnltydmswqga +gudzjlwynbriaqvsphto +ldtacrhgopvqzywbsjn + +rvpbylxcuajdh +rxwjpbedvuayl +yavrpdlxjibu +riydhaplbfcuvxj +ibpayxruvdlj + +gojpz +hmvkeqbxr + +znwovmahqdcefrjbs +crnjswagzqmevhdofb +sfchdgxqjmzviebonarw +zoqbcwdvnshfearjmt +snhazkomqjvrcbflwpdye + +au +au +fbu +oglu + +yzwxtvuhdaeo +bridg + +ljndxc +nxjc +cjnx + +dyrwejnmuqpxolakgbzhv +vxmnpagycwquzlhdojrsebk +umhalvgjenrxpydwzkobtq +nytrhgplwdjkioumbexvqaz + +uyakmhxqifbdjer +tmeqpsfahxoruw + +l +y + +xgw +paxdsuof +xw + +ztvo +ixu +lrnkj +zxq + +foxkjaehwqcntiu +fojweunxikahtcq +hjtnwcuifkxqeao +oqjxwicklaehtupnmf +jachtnuqxwoekfi + +btq +qtbv + +ra +yasr +ncmvroaz + +pevfcuo +rivmwztqy + +gdmlczw +mpacxyolh +lcrmi +lgkecqdtm +rlktmdcf + +itkzmv +kizt + +ksxgfjrtvdqybwoze +jgzydsxtvwbforkqe + +xtfmoew +gzldprhy + +mecgavlynobxupi +jyohgertfnmuxz + +rakfugnvxpi +funvgpia + +xfurihg +guhdrqix + +qo +q +qv +mrqp + +cuseonqthxpavmgd +ynhazdmkfivjxwope +hzejxiavpnkodlfm +zbexajlphdmvkno + +dotnhqgu +nguqrv +unoigqr +ncuqgp + +wfinrjsmlxzchqpv +hqwljsfkxnmizpcv +qiswhmrpxcnfjzvl +cxljqizvnwhsmpf +qhwsilbczxfpjmnv + +n +thes +s +wpkadjgorxcy +mue + +upwxeatcm +mpwectyud +ewvtumpyc + +pglamhfkcsyoeb +hfakeosglmcpyb +gesmyloacpfhkb +ksemychfgalpbo +fgohpcklsemayb + +bn +unb +mbdn +bun + +zmwfyakq +swaj +twrva + +rbkcgzqvp +oumthkfnia + +wsadpbj +biznahjxc +azblmj + +e +er +r +ge +tb + +nzq +cldif + +hlswofngtjda +ajvodlhtsw +whaltsodj + +fe +frcbep +fe + +cgjlhspvnmiut +jgptuchmsnilv +lcdnguvhsjmxipt +psugwjctmihvnl + +r +ir +rwk +rlgj +r + +ypakce +pyjxchkeon +cpgyke + +ksilwgqtud +kisldgtqwu +zslgqtikduw +qudilskjwgt + +jquan +nou + +szfq +qszf +fqzs +sqfz +fqsz + +kriwjoyabgslfmx +kqjdhnuei + +tocqzagpnbyd +sxunfeaicptv + +r +yr +tru + +d +d +tkv + +taondlyrxhv +nhbciefzudw +gsmpjqk + +kbrswhqj +bhqswkjr +qbrjhskw +hbkrqjws +qbkujrswhn + +ruaqvlfb +fduniqemlgab +bkaqlfu + +pesctg +tjpesygc +mpcgvst +cjsbwptkg +gsphtc + +jwq +yjpkzi +wj +qujw +j + +v +v +v +v +vg + +ynwlevxsopbuc +luepovcwbnsy +nwvcusyplokeb +jscybopflvuenw +eoysncwuvblp + +qhjtyuxdbcgsfomnl +tlyfnqbmusghdjcxo +htnfqbcmujsxlogdy +buysgfjtnchdmqxolr + +dr +vri +rmunz +oashgr +kmlvrd + +dqhsjgrak +qxvlgb +xgpqbu +tgenibcmq + +f +f +f +fy + +vyukhwopcxbmjgfq +xchljnpgryq + +b +b + +ewmlqdzgtsaf +zvfrbaysleqogtwm +fqatklgwumhzes +lzgsfmtiweaqcx + +sqxazpginrvbmoflectkhyd +igkxqsdahmepcybrfltzov + +qf +d +q + +uhvndserfgt +cmdethsfurnygv +tfnvrugeshd +gfrsntdhveu +fenhsdvtprgu + +nkm +km +mk + +dw +z +x +ud +vi + +sleyfmcvigp +ytneopvgcms + +c +h +j +r +h + +jvxmidzkg +nqjuzkvcxhpid +dzjkxgvifm + +hwgzm +ucaewrs +ywjkgxt + +tewjlngvszk +tnjkzve +agjhkznvesqwrt +kwztvjnaedl +jpyteikxobncvzm + +uxcpz +pucxz +xpbczu +xzcup +uzpcx + +cfxlvkiswmgzrtjuq +kfxcqtnmrlzjswvg +hxetzclbjfmvwsrgqk + +fpaxlvbzwnqkgsj +xczqlbkwgapyvsnj +bwzalgjsnqpxkvr +jnskawbxlpzvgqe +wsajkvygnqbzxilp + +zuhimpjlbfogqkn +ophznvgmfuiakj +njhkpfiomguz +okufhjdgznipm + +fpsmed +shgef +mfse +esqfv + +xkj +nk +ndc +j +gh + +wkeocxgtds +xekgsowdt + +n +n +n +n + +rpgonuykqjawhfdxcmzvbe +mhtrxudpnvbezawcyqjgkf + +wtoveydlszxngqcbiuk +glsktqomjwrebz +hwbgulqtzoeackyvs + +drfxcnjqsyug +dsfrniycubx +cyshxnkdrfuzv +cswmnxaylfrdtu +cduymsxfpnr + +htnpxifrlsmgev +ohwmykctdnzquj +htmsfbanlx + +sigvmu +gvism +gisqmvprlw +aigvsdm +svpmgli + +msbeiuotwyrq +ebykoiswt +wkfyeitaonsb +wiogepskytvb + +xcimgdsvfkhzonlb +fkdsbcohnizgvlmx +cizlnxdkghbmosfv + +h +a +a +h +b + +kyqg +sohnwprx +zmb + +msw +mws +swm +msw +wsm + +xopjrmh +plrshdmwoax +pxiromh +xmpbhorj +ijxhpmor + +acempwkqxoglu +puhqcvwadebsxj + +xaiwnyl +yowxn + +lbynjvihxe +dojvbhlinyx +hxyvbijnel +jlxihnvby +xhnbijvyl + +gkewxnjbc +sztpavcrkyqmndhi +cguknlo + +ywgpaoermuizc +wrmpouzyicgea +mzpecogtuirayw +opriuamyewgcz +yuarigpoemcwz + +tvfj +bvtj +nvftj + +opjlskxcfgdrwmav +jmrhzacwdilpx +dhwjclxarqpm +bwcmpardljx + +gtr +oajst +t +pwtg +utg + +cuwpi +wcupi +cuiwp +pwuci +wpuci + +icrlgewdmu +lhricgdwme +lergdciw +kwclifzredg + +rnpwzhlqmkafov +rmnfzaldqokhv +hnrfakqvomzl +okvrhzqlmadfn + +bwxpgnrovqs +vagbromxwjs +kxfsyb + +nakv +nkva + +bzkg +vgkz +rkgl + +oklyx +kylox + +ibw +wib +iwb +izubwxv +iwb + +zikvprafh +pnajkvzif +vmiaxbkptzlf + +mbouarxetzqcfg +hmojusvzelgnad +zigdupoylmwae + +fsjyboa +pvhzlwkima +djrngxuae + +ozry +rzoy +yozr + +suydqovzgel +ulke +bluwe + +uiykabnpgdxhlmoz +enhigdubzkopayml +psiagkznbmchdoyul +ukinspbamdgoyhlz +opnjmrkyughzbalid + +nahxju +pxhnjua +hjnxlua +jxnakuh +uaxjhn + +teqaxpfjkiovg +gtfpijeqva +gfqepivajt +pavegfiqjt + +kglixrmouhyjbfvt +rkmlwixycujhtfgzb +frpasbtmugyhldijxk +rletbqjmfuhgixky +mwugybtjhokfxvnril + +qrtpdcvhnoljbi +gsdphvmotljb +jvbpkewotl +lvjmnuozptb + +zrxesgvquayc +syczgvqxreau +xlaeumyqcszvg + +ojfgyctiksprhavmxeb +yvcsjobgetrxkpm +spjorevcqkgytxbm +gscojxrpbvdtlmkyen + +otaibjyzxceu +xzceiyubojta +zbjxaieycout +odubiyxtacezj +ugowzxitacyejb + +pfqwxeumsy +fyupexw + +lnmvxqswzh +npstbrhcx +tmhazxndsg +uhnsrx +yjxnhoksie + +xmrzgnis +imnorzs +snrmzi +qitspdrmzn + +ws +ws +s +tqs + +ndo +w +wl + +moazp +pjz +zpj +jzp +pz + +hwgdsjvkyteo +wtqzdjoy + +ntzbhs +zsnhbx +hbsnz + +kqztidpsmboyung +phymuiozr +xaoumiyhzp + +kejuifmox +mfikxuejo +jifxueokm +iejmkoufx +ixfkemjou + +auw +gudkr + +sgenlwuohcb +ghekwucxnq +xncujhweg +geuqxncwh +grewnhcu + +lomvbqwzrsgfeiajhntdku +vwzytogdmhkinecafjlxprsuq + +pgleaswzbd +zaswfkdhp +apszwd +wsapydz +atdpzsw + +wxhonybje +ojnwyhexb +bejxhnywo + +olsux +zxou +oux +toxum +xuo + +gxaebkqydnjzthirmcfpow +gtxiwdykrzmqohejcfabpn +xfaorpbgywzdncqthkemji + +eglacoibktsdhumnyx +ukfxoetsbcwmqjigah +sbvughkyocditlmaex + +tsumebadoq +oeqtusbad +piuohxndabqtrs + +oty +yo +yo +oy + +zw +tz +zsyuk + +bpruyqoen +qykbfrzpeo +yeqpbor +nreyqpob +pyrbqwego + +myrhzftueikx +fvdetmlxpcwsibhguk +ahnijxufoketmq + +gvxfsulkyj +oknycdfrelw +flky +lfkgyx + +dtgsf +tgfd + +rsdag +adgrsf +fargsd +rjagdlms +gdrsa + +ehurysjqofmtk +ytrfmuokesj +yvjfraemitksnuo +ueoyksjtmrf +esxkmwopgfycjlrdbtuz + +hl +zfo + +ieduqnyk + +gpjisdyezo +kynwfce +vykerc + +wh +wh +h +lkho + +i +xhl +x + +utzexphayjw +jyzwuethapx +thpueazwjyx + +rk +kdr + +oquelchwfivxakjmrpyzd +mjavklucigqwoyxezrpdhf +xzcuohkplafmwjdivqyer + +uy +yu +yu +yu + +wnkdo +cpkogadyvqtr +fdokh + +mxgktesjocbl +hetucq +ypizcret +evctaz +qtce + +zlidyjfbhopmxstcnrk +epqbhldkyzsjnfaoi +lkbnjisydhpqzof + +eiagoyskthn +hgxtaivrmyplukobz +gyokihwat +gafytkihco + +utxdvi +duvixt +xituvd +uidtxv + +oxeyucapbnk +wtxmklujney +fxesykubhrzgona +uefycnxrvk + +qpjnoavemkgxfuydlr +rwqucktobjelyd +dqrcuosyekzlhjt + +jvaecytfpmxrdq +safuytleohkxbdvcipz + +oizutcswja +uzwcti +wcuzit +tzwiudc + +waphtlmdxzckqirb +mekftdrwzhjqxsplcb +tzkqdplmhuvy +hxzcrtkpqflobmd + +glrfzsdbu +rfgdlubs +frwconquxylbsagdh +tgbfslrdu + +dulbtwyp +fgct +trhkxa +nejhstv + +zjgdsavc +dvgsacjz +sacgdzvj + +fjsgwkziy +bwgitfk +rhkdpiwg + +jfygdqpchxneb +jpwxzsbn +mrajoptnlvbxu +mxpbkwnji + +th +fht +th +ht + +kijvchy +aivjkhcy + +fsqtcplo +tlcosfp +slocfpt +tpflsoc + +gkc +gqck +kgc +cgk +xckg + +swqxzdtmfplhibyjrevu +izhfjltywpmrqbevdsxu +evtxzpflqrjsdbhmwuyi + +kdmbvqcg +pqckvdmb + +witrzdagcbyux +irxgyuazwbdtc +gazbrywcetdxui +axinyzgrcdbutw +trbagmluciwkdxyz + +uwbhvdy +wuvhcy + +ygjqzpdrtsi +psqrtaidjgy +kmsghxlqnidtjp + +cprkdbafqlwuihgvys +yubzxwmvogderf + +xabnqejdtcw +dqtfejnwbmhxac +dwnbcjqtexa +wvabnxqyjetdc + +pzo +zmnr + +v +v +v +v +u + +lht +qlth +hlt + +lx +xl +lx +lx + +eazpcoihwxmtudsyknrq +qldaiztcpoeynskwhmur +cobzyspahgrkinutdmweq + +qpjm +elqujm +jqm +jmpq +mjq + +oltnpgsmhbqwzexvikudyar +zyxqhatrgsenwlbokdipvm +eshotqirdnxbyklvwmgzpa +zeaqwofdpvxytrikhslmgbn +alkrqdxyeswmgnvzbhtopi + +wzbhmvrtiq +wtimqvzb +ifcobmgwznvq + +fgwtjydp +gjtwpdyf +pyjtdfwg +ftwypgjd + +qmsfcxwdopnj +floqiwdmx +wxohimlfbdv +xakwymterdozgu + +vrlq +ulhdwsmr +hrufl + +gohrfpw +brzdtl + +nhso +hn +nh +chn +hnd + +myzkfxprtegohl +epntmxyoglr +tyqgiloxnperm +dgoewlrabcytxmpjs +urlyoxmpeqgvt + +aiewv +wrativ + +tglwzqhrjexkf +fuazgyqkvxrj + +priylwgbfn +gmlbpiwfn +qdbginlpafsw +rinblpfwg +niwplbgf + +zngjkchylqi +yfilnjschgzeq + +wvmbrui +wxg +kwjg + +ljvueoishfzabyw +ruwkeyzigsljaof +jyiwnzleafotsu + +mcxv +jmwg +ktsnm +toim +mulyfrze + +ku +ku +kuvi + +ulotnbfrqcadkmjivpxgeshy +qcegdpwszryvjnuxmbohka + +rfikmej +ctagoqzldvhnxpwuj + +xpjwiftdynkcz +dxvcqtn + +nelkupxgrmtijasqbv +qvilfbksnjgtepruo + +x +y +d + +qnzorg +rqzg +grzq +rgzq +gzrq + +wqmofz +tlm +ml +mp + +bfszturqkoxymjh +hkfuoqrzemstxyab + +xevanum +efvmnax + +bouykivwld +mbrnfczq + +upvexa +aexvupsy + +c +c +c +c +c + +h +t +t +t + +jati +tiaj +tiaj +tija +dptjia + +vksjnyti +bvlksta +tmxvzpsc + +ksqwt +stmqkw +qskwt + +xcupr +iue +uwt + +mznesjqwdu +eudhitwm + +jmslovq +jsdcvgb +imsvj + +oiva +izo +ig +crhi +gizj + +wlecpsqrdh +rdextqhwpc +prdnhcaeqvw +rwdhpeqci +qurwjfhdlpec + +tkaoh +xjecrywq + +xeni +gvt +eft +pomsjacq + +cxv +q +t +u +r + +qw +wfq + +oabsdwtgvqiuphnfexjlzyr +ardwyhflepinsqvbuzxgj +rswgxjdeyiphzvfulqncab +ywxvruidnsazlpfhqbejg +dfyvncgsiaezrhlxwbpjqu + +jeklahmztuxnvqgc +jlhmekvugtqcnazx +hamkqunjztglvecx +muckejgalvtqzhnx +zkelhjncqaumvxgt + +bwikegxcfoysruqvh +htpucnivmjzlad + +qntrsyigzmha +aqtspyoxi +bwuvsyjeadiqkt + +sfyamuxco +jdqfykzigv + +plbctxfsagrdmovyz +oyhaesxcgznlmbpwvrt +pzdibfsocrvtlamxgy + +mkvdbpt +dkvbtsp +xbkptwhd + +pgldyjsqunafzit +olbzkdscvymhw +sybmdzlxore + +pujqcnoeisagyv +qjcevnigaypuos +ceunsjqloaimvygp +niecoypusavgjq +puqacjoveisgyn + +ilhxmtzjs +jsitmhlx +sjltiexh +lxhtsji + +aiforvklhzq +zivlh +lgzhiv +lixjvhz +ihzcvl + +fsztenwbpuqoai +cpvkthwdlrjuy +jwluyptg + +qdjgnkzsputbvhlyoicw +rjipmyqnfwukstcoxzghblv +ucjyndisqgwvpkolbthz +nbjsizouwgcvplthykq + +bzuyelgj +ubeljgyz +gzjbylue +zljgyeub +byjgluze + +quk +ukq +upqfk +ugqskz +usrgkq + +ftajvlypimzxshdcqnkwure +dnclmiyjrpzxeatskhwufvq +dpxkfzuevlatsijnrmhwycq +qnjvmukyciwzxpfdahlrste +fmzcxnaerptujisqhklywvd + +krty +pths +zcotin +uyzt +tqladvbejgw + +kcyfjpzre +fknbmoajc + +fwzliqbamsg +biqamolzswyjfg +zslamfgwqbi +lxaqtvnhsfmpbcgzweui +afislomgzdbwq + +vroeixdqfcwszaukygjlhp +wrmzvklhgoyxdciaejqfpsu +cqghksdzuwjvrflxpaoiye +dkxwcrpszagifyjlqhoeuv +vqkoywerdhgusaljzpfcix + +nfcuoishtemrqyxjv +clrnxheqvoiuytfmsj + +tkrqbu +ubrtqk +rukbqt +kqutrb +gbutkqr + +xie +ixfe +eaknmyi + +mjlreiaczpfbs +ibkehz +bezwxio +izthqbgue + +cxegof +qrotsf + +zslba +lbzsa +lszab +lebdsza +wbzsla + +pnrdfmhqgbyc +bprgnvhyd +nhpdzeuaiojsyxrgtb + +noeytqbsxfrl +obfntxlyresq +exybsrtfqnol + +iwyg +ygiw + +fcha +wma +zhanpwe +lzfaneck +bjuxogiavqt + +pbjwavkdhczy +baywzkqjvce +vsjygktbczwa +vwzijyblcaxkmou + +ryl +rxq +akcvpwr +lr + +oqzty +yitqozg +zqoyt +qyzto + +hugtzim +ingzchuyd +pkhuzsljxi + +jx +xi +x +x +x + +ofjhxmvksergiwybtcu +tolphrazkdmnxvjqbgwfu + +fxchrgezya +egyavxfzhu +qazgfehxcy +yizpxgfhae +yefoxgrzha + +fdeycphozusnrmlqxbgkatij +ibcljzfekypxraosntmdhg +rclgbmydkifnzhtjsxpeoa +ackshxdjemipfrgyznlotb + +wumlxodgzvq +xrzkoqgmludvw +qzulvoxwmg +wugolamjqisyvx + +jizxyhqgrnawmpueo +pasuqmtjnexolvr + +xkguqypbe +osgkvxueib +nxsgekoub +gekvdxub + +kngxpdyotlzfejvswcm +qplsjgtownxahbdrkfu + +zjqeomhnt +tojeqhmnz +mtjqozhne +ejozmqhnt + +syzqrhiwfp +hmqewc +vbhsqfn +tgaxkhqlo + +fyhucdtvsk +kfhcvudsty +stbnyhuigkdjfc +tfycshvduk + +rbhqwkjdvmpxageitnoflzy +xkthmoywqeidjplagszvbrfn + +ktpfmlvsw +mvsklwtpf +wfptvklsm + +rnlvdy +nxrcl + +elwycpbnf +ncywf +wcyfn +fvcnwy +fywcn + +bckpqzdwosyfvnut +oxpvukncbdwfzqtys +fzwpdtvybnscoqku + +cbmrsxdipyfnvjo +mnpabkgqslufwx + +kywscxvhq +vruiyhsezt +fjgnmy + +qbjdkgltunyfaxsp +psblakjyedthnu +punsydztlkcjba + +bphcoy +hbpoyu +bkopyq +atilojrpmby +pbyou + +ibluxzvfswnghc +gwsfplu +uglsfw +lusgfw + +sjlubyimoegkpftdavhcrqw +amouhdfilybrjgetpwq + +orawjpscyfdnelztqbh +sawekclfpnbqzodth + +ntjuvmwpycf +szjagiteydvnmplfwc +myrhnvxwpcfjt + +rdosc +rdosc +dsrco +rodezcst + +ncugi +nbgwup +ugn +nug + +n +n +nl +n +n + +ntflyovsdhmkcgp +kantmvyrpdhglio +tnkvpidloymbuhg +ohtvdypnmzwkgl + +nxqs +nqx + +jp +jp +jp + +ejskx +oryamnsvzg +hdjs +uwtsh +sh + +bpcugtovs +gweokzqstjvlp +gtduvshopria + +uthdirywmvgbxe +zugeithvrynm +yoivghmuqtr +typsgmlfhrivuk +erdvuimhtyg + +eydpbq +dbyeq +yebqd +webdqy +debqljtyv + +munbwc +lnvu +nu +nu +ynru + +gftdzau +gufszr + +fyxzhbwnuptil +sygzkulwpqfinht +tfwuihlcypbdnez +pnhyzmulwfit + +acryonbgetshwjfxzml +ozhmrcfalxwytbsugej +ehybxrfjcqtsozawgml + +z +nfej + +mhvxlkbtuyo +hfxqabklvygmc +ykbmvohxlws +ekbxvrhyml +yobvuwhlekxm + +ambpsyie +bcimpyase +ebispmay + +lydzmsgoqijxkthcewpbrn +ynlpjgqrztobhmkedxsiw +jpwrluxgbismezdnyhqtko +vrdkxhnjgeysbtofqmwzlpi + +mvkyralfjqtu +iazljont +tzdclaje +ltgjza + +nsizhmgdoewlvx +lwghmdxzovnsie +doghnvsxewmlzi +lnswzoivdmhgex + +cadutlrvyk +xaouyv +vygua + +z +w +n +n +n + +xjlvfhcgbqyozt +zcyqbtgvljeofh +yczjfqouvdtgkhbl +gbvzflyjhcqot +ftbcoryzgqvhjel + +fnkspvetum +edmstgnqkjvx +puesnmvkita + +ytrbqlwcvusz +qmjcl +qcxl +hxgclq + +ldg +d +d + +sc +cs +cs +sc +syc + +axpdoftgkme +adleukosgxfmry +kgfeonazbdmx + +muxqr +rmqxu +rxmqu +ruvxmq + +qhidvckgolepxsuj +zfvinabmcewpkgt + +pcvmxbdo +wyodpmcx +ojgrdxcpm + +jimg +mljsi +mji +ijms +imhzwj + +jfkbp +zndqof + +ed +tdef +capdkyize +etdf +edtqv + +vhm +hmv +hmv +hvmt + +vylapqueifs +vpyqilsfaeu +paqefisuyvl +svlepfuqyia +eufpvialqys + +jowmpltbdxyrvu +mudxhrcbfzjqslwptk +dbrtulxpjgywm +uwpmtjndlbrx + +ilnxbpwdrvuokfjgtzec +inxbtyczgfjwdlveour +ohznidtmxuawbcgvlerjf + +q +q + +xmjs +smwj +jsm + +cyfp +soxgrjm +pu +kfhe +tw + +rhuey +uyhrge +erhyu + +d +d +tmd +d + +muciswt +stmic + +ldxnfy +nqler +nlkb +ln +lbn + +eyqhbgiwfkjlnx +wtekhamon +zcseurhpnk + +xumhwodpjfgalqns +gozkaxbrwvc + +kioucnzelsy +foyuvzceiknls +ksenoulzycmi + +nefyugdromqbiksz +isomrdufqbkgzyne +pesmfngbrkudioyqz +gsmtfeodynqkubrz + +xskygfdipzwchrlvatb +dhgawjcpirkmvtflzbxys +izrvshfbdwlapygxctk + +mb +qzmayl +fmt +tmh + +csjthr +tflbks +bstfpda + +qojyvbtusn +ovsxbhqytuj +weojbisuqytv + +aepz +eapzb +apdezm + +syoeagjvfl +fejtvnmqxrphzlbc +fgviejsukld + +ylbqv +qlvby +vyqbl +blvyuheq +qyblvz + +evusaopzdy +zvypducloea +udvozyepac +adystoeupzbc +gzmpdaeqwukyo + +fglqnbtpra +robpaegfktnq +mntqfaiprklob +prjfybutdwaqncsh + +q +y + +rcz +zrc +zrc +czrf + +rh +rh +rh +hr + +aynwkrpfuvhcblqtzixgeojsm +mvtpirakxuhwfyjscbqgnoezl +mlcuqzoihdgrxfvyswtbaejpkn +rpialswqmbnvehcyxjfuogztk +amkhqocevbwxlifsyrntzgupj + +rljduyhgnzwkp +kuydljrnpgwzh +uykgjwrdplnhz +ngdwzylhpjurk + +wexrly +yxqlrhemw +rywxle + +t +e + +pxhgaqjv +rnjxltuqh +myqfwekcsdix + +gwdfvsolhup +vlgdwuspohf +fdrvuwopslgh + +zhsrfjbcndwqyvupgakemoxlti +xhtoyfnlwpzuevgdmbjircakqs + +ldgebj +jleg +jugle +glje +egjlu + +jlnzs +nj +jn + +jfhdwsg +ltkpanyihejxsg +hsjrgmc +gmsfoqhwjc + +evjngcfizyuoslpb +ozbsiefngjvpcuyl + +pjbred +jdtbkp +awdbjko +dbj +vmdcbjhl + +iudzrx +agykxzu +xukzpa + +ou +huo + +l +l +lb +l +l + +hfpw +wphf +hpwf +lfpwhc + +wajmh +tqfpcselurxi +kbz +ywg +dkz + +sgw +cyezglipksuh + +oexibpzgr +pixobge +xvucyptmqib +bixozp + +va +o +wnjky + +zevpulnqaikdmwsyotcr +dzvkjeinuslfrchqmgyw +vezxklwdqynursmcfi + +id +dvi +sdiz +ids +idq + +bmpxyk +cnykjbmexo +xydmatbki +dxbymk +myxbk + +atzibcu +ticuazb +icazbtu + +nypbqmhuc +sjqzoetl + +dxumvboftrwzihclgqeyk +mhrfecdvzgikxujyqtpwbaol +nkobczmqytrlefviuwhxdg +vgcelwryqhznbtfxkmiduo + +fzxyjegvadrltb +rgehucmqpn + +nfrx +ufxkverj + +haqu +qk + +fgchqktrynjbwduia +umnljcwifthzqpovd +xwenjtqihdrucsf + +zkjmoyh +oyhmzkj + +xdsoglwprq +xlmwoqg +luqxwyogm + +yp +bgiw +l + +liefqvj +jefiqlv +efvljiqr + +axnpoecuwibslgd +xeougsnz +smxgueony +qexumgzonsh + +wua +adwiu + +n +nk +n +n + +maijgrtsyn +sjytikamrgc + +cwnetku +gilvzhsa + +hywvukqdmjiezrbtnplacg +ejinbtdzwgmkyqhrlfcap +uimwlzrnkbqgjvtacyedhp + +grud +dxuerg +urdgh +diugr +iurdg + +tfwiqjnmbue +puylasdgzocxh + +ysghmdqol +omlqhgd +imqohjdxrgl + +fkayurzxndqieobvht +qmrnbfkahieowduvt +cefarktbvhqiound + +qptdrbmzgk +dmbq +lbfcq + +tjxkogms +dcphwbfulxenrmzi + +ohreptydvgsiwnubkz +vbgkoshpdluzeyirtn +xiqskhnadmjtgyvbrpeuoz +oknhrzvgbepysutdi +ynegfoubrdctsihlpzkv + +zrn +rzn +rnz +nzr +ndrz + +hpgliyawdbsrxfkqjen +rsdielyjxqakphwbgn + +qvcjphegszrt +tjcaermgsvz +dgcjfuapeozhsn +gwexszycjkibl + +cmsjwrbudoi +ezqwslombvj + +glw +elo +mrxkctaqu +hnsjf +jwvbi + +kotwglnpf +pugtlxn +npltg + +gdxpkcyuqezlonsfam +wjpsozehatqyk +izykpvoqejas + +xbjouepi +samvuxp +xvprzu + +rq +rq +rq +qr + +ocvehwzqfurayknlix +uxekyhclarqwonvifz +wdruxcqnkohfayezliv +oqrnxawlhycuziekfv + +xpcgsrelqw +mwdrceplsqx +pehrjxcswlq +seluwdrqcpx +qwpeucsxrl + +d +u + +epijobawgtdqrylszxnf +rwpxfzbeyosadntqjg +fbxwyrcepozajnsdugtk + +dtecfku +eiutfkr +tefuk +fteku +lktuef + +dmrwnhbq +oimnyltvqphze +qchkmsajn + +nfw +nwf +wnf +pnfwq +wnfe + +brw +rbw +wbr +brw +bwr + +pyuxqzbcnmrdwjkgsoe +jbudewcygrsqxtpmozn +gzsibnfydwrcjvmxkuopeq +whnoypqjrcgulszmbdax + +pdfzoknvgbr +fgokwnzebdvrp +borzfpvnkglh +krfgplvznob +pgvmnzbcfkroyjs + +jgszrlwvi +wvonhpy +dnfmtwva +kvqdtyw + +xrzhqlgpevtcwm +ehglzctpxqrmwjavu +clmhowtkgpiyfqrnbvxsez +vpzhmrxqewdgtlc + +waztysmcegnurkvjqdp +vosdabjykpmgzcnuwr + +bwutrjc +urbjwt +jurztwyb +utbjrsw +zbwutjr + +zeckigrwv +zswgrcivke +ceywkizvgr +kziyvtwcge +gzfanbvwxmceidkp + +n +n +n +n +n + +mzwbnksrt +tomrwnkzs +mknszowrt +ktrnmswzv +mtwnrszk + +y +y +y +y +y + +rmbditwshcfkpjnozavyx +dyftmzojakhrpcwxsvnbe + +avdbct +dvatb +amdntlovb +vadbtc +bavtd + +ruyvefoqiaslcdkm +iaouvsmyefkcdrlq +uqoescaifkbvdrmyl + +dkvxyjsbwhqac +pcjbqyaeuvgfostx +yrdxkqjacsbvm + +ugepzw +derzibs +jyokqvmal +fhc + +qupyrj +ibmzegkto + +xksviqnyurgw +vkbnurxlyqg + +opgw +smbvpg +bpds +gjp +fpta + +xtlncsiwjhbygrdoumzkqvaf +olsxbuwigdzmhvtyrajnqckf +lajzbuqswcnvhkdfomxtiyrg + +pakwbfxuq +wxpafkuqb +bkqpufxaw +axuwqkfbp +uxwbfpkaq + +eqsgztjkimn +nqjzyst + +cn +nc +nc +cn +cn + +rv +rv + +pbwsuy +jshcqt + +vbjkzyprhm +jkmbrezygvhup +rhjvmbpyzk + +ochfjrqmy +qrfocyhmj + +ksrx +hcrbzu +rdc +jrcp + +soixrchpvek +qbtdocpixwalfvnkm + +zmtlj +zlpyjtm +rthxldmjaniz +zluptjm + +rcyshqp +jbdnpe +zgp +pnjtz diff --git a/2020/06-Custom_Customs/second.hs b/2020/06-Custom_Customs/second.hs new file mode 100644 index 0000000..10d0ff4 --- /dev/null +++ b/2020/06-Custom_Customs/second.hs @@ -0,0 +1,25 @@ +-- requires cabal install --lib split Unique +module Main (main) where + +import Control.Monad (void, when) +import Data.List (intersect, foldl') +import Data.List.Split (splitOn) +import System.Exit (die) + +exampleExpectedOutput = 6 + +parseInput :: String -> IO [String] +parseInput filename = do + input <- readFile filename + return $ map (foldl' intersect ['a'..'z'] . lines) $ splitOn "\n\n" input + +compute :: [String] -> Int +compute = sum . map length + +main :: IO () +main = do + example <- parseInput "example" + let exampleOutput = compute example + when (exampleOutput /= exampleExpectedOutput) (die $ "example failed: got " ++ show exampleOutput ++ " instead of " ++ show exampleExpectedOutput) + input <- parseInput "input" + print $ compute input |