diff --git a/input/day08 b/input/day08 new file mode 100644 index 0000000..a75f9b6 --- /dev/null +++ b/input/day08 @@ -0,0 +1,200 @@ +dcga cadgbfe gecba cbfde eda cdbea gbadfe fegcba bedgca da | bgefdac bdace ad agcd +fe ecf fdbagec dcgfab defbca efbcga daceg cfdea bfed fdbca | aefdc fbde abdefc dcgae +fbg cgafe bf bfdc ebdcag fgcdba gbdecaf bcfag badgc gdefab | bfg bf bf bdgeca +bgedf gecabd cd cadbgf agcbe aedcgbf ecgbd ecda agfecb gcd | bdacfge cd cade dcae +cedabf gcfab cad abegcd fcbedag aedbf gbedaf dc ecdf bdfca | cad dc dc bedacfg +ed gfdcbae acbdfg ecgd cdfeag fbdage dfcae fbaec eda gdacf | dae fadgbc ecgd aedcgf +dgb gb dfaeb beadg cdaeg bgdfae bafg cdgfeb aebfcd gcaebdf | aefcbd bgaf afgb dgb +fdabc ef cfaed daebgc fgebda fde dceag gfce cbgfdea eacfgd | adceg edbcagf edf fe +dagebf bdc bc afecd daceb cgbe dabceg edbag dfcagb cefgbad | dbc dabge abdgce cegb +dfgeb ebgfc dcabef gcab bc gaecbf cdfega cgfae bce efabdcg | cgfae cb gcdebaf efgca +afc gcdeab gdbfac bceafd becad ebaf fa faecd gfadebc cedfg | cgdfe afc acf af +dcgba gfabdc edgbfa gfdab bdc acfegdb bc adgec bgfc eadbcf | fdaegbc gfbc bdc cb +adg gbfac acdfbge fedca cdgfa ecafbg aegbfd gd cbdg gdfabc | bdfgac fcabedg agd dfbgcea +fdcgba bfc cfadb aebfd acgb cafgd fgdceb gcdaef cagbedf cb | bcag dfeba agbc cbag +gedaf afbcdeg ecgadb cbgafe dc efgcd dce cgefb cgdbef fbdc | bcgef efgabc dc degfcb +abdgcf abefc fd gfbacde gcedb gedf cfd edgacb fegbcd febdc | cefdabg bacef fcd fegd +faegbc dfcabg afgbed daebc eg gfec afcbg acedgbf ecgba egb | eg eg bgadfce baegc +edfba bcgafd edbg bgadf ed adefcg gfebda ecagdbf efabc edf | daegbf ebfad ceafb bgde +fcebad gcfebd agcdbfe daefgc gdabf cdg becg cfbde fgbcd gc | cg gafdbce cbdgf gfdab +bfceadg dfe geadb cgfd edfgb gdcfeb cabgef fd cfgbe aefdcb | cgdf df agbde edgcbf +age becfad cfbeg eagdfb dfecgab acfeg efdac dgac cgadfe ga | gfeca aecgfd eagcf fadcbeg +gabed efabgd egafcd afgecbd adefb bafcd gbedac febg fe fea | gfeb fe badge adfeb +edcgf adgf afgcbe ecfbgd dcegaf af dacbe efacd afc cafdgbe | fa edbcgf dcgfe adecb +dgabfc dbagc cbdgea ge decagf geba gcbfdae dge bdgec ecfdb | abcgd dcabg dgbafc eg +gadfe fgbcde afgdbc ecfb cf edgcb defcg dbagce fcbgdea dfc | dbgec adgbcf dcefg fc +gfeda abf bgfd ebdfgca gaefb debafg fbeacd fb gcdafe aebgc | gdfb fdbcaeg gdfb bf +ea eab ceabg deac daebcg gedafb bdagcfe efdcbg cgbfa bgced | gfaebdc acde caed dbafge +eg cafde gdfe aedcgf fagbcde baefcg adcgb eag cfdeab acdge | bfdcaeg eg ega ge +ed dcgbe fbcadg gde bcagd gdbace dbea eacfdg feacbdg bfgec | ged gbadfec cdeafgb acbfged +gcbdfe bead da ebfdc adebcf ecfdbga dcfbag cad decaf eafcg | egdcbf dac bcgfde cbgedfa +cgafedb cabfdg deagf gacdeb eb cbdaf bdafe aeb bcef afcebd | becf dagef befc dbfae +ad gdebcf dabcgf afbce dbga ecdafg adc bgcfd cadbf decagbf | da fdcab cda dac +cebfd ab cebadg fadgec agdb eab caged bcdea fegbac dbcfega | bae ebdfc ebgcad bdefcga +adegcfb edfba abdgef afcbd dbagc edfc efbdca fc fac abgcef | bdeaf gebfadc faecgb dabfe +bgfecda dbceaf gabedf gdf fg cgeda bgef cfdgab fdage aebfd | badfe egbf efgb gfecbda +deafgb bcdge df dacf gfacb cfagbe bagdcf gcbdf ecabgdf dfg | fbdgca dgf dfg gfadecb +dbcafe gebcfad fagcdb gecfb cgdeb adeg cbeagd cdaeb cdg gd | edfacb gecbf dcg dcbafe +facdeg cbefgd bed cdebfa egfb gfecd ecdbgfa be dgbac ebcgd | ebfg cebdaf cabegfd gfecd +bacfdg cdbaegf caed fcbge cgebad gbafde cgbda egcab ae aeb | gaceb edfabg cdfbag cfbeg +adfgc fgecad gdabf acbg gdafcb fcdabeg gdb gb dgecbf ebfad | abcdgfe gcba fdabe gb +dfbc df adecg def dfeca cafbge eafdbg bdcgafe cbefda bfcea | adefc df efcda aecgbfd +aeg gefcabd agdcb dfgcba egbdfa bfeca edcg ge bacge cegdba | gae cdbga gea eg +cdegb bfgc bgd ecdag dgbfae edcfb bg dafbce edfcbag dcfgeb | fcgb efgcdb bcdeg gb +gdef dbafceg cdbeag ade gfcae fdabc de fedac efcbga ecgdaf | aed dea gface agebdc +gdeac ab bga baef eacgb gbcafe bcgef bedcfg dgfbca gacedbf | gab ebcgfd fgdeabc ab +efa ebagd debagf gefb fe ebdagc gfdea egfcbda dgacf dbfcae | afgdc gfbe efa bdegca +daefgbc afecgb fd cfbdg fdg abcfg cgebd abgefd fcadbg dcfa | dgf df afcd dfg +agf dgfcea ecfg bdfgaec fg dfaecb abgcfd dfgea baged acdfe | fg efcg fag dafeg +aedcfg gfcae cdebg gab ab abegc bfae aegcfdb bfaecg dbfcga | dbgfac dbgce ceagfdb ba +bd afegcb bedcfa adb dgecabf fdeb bfeca acdbf fcadg bcagde | ebcgfda db ecdabf daebgc +bdf fb dbefcga edfgc fbga edabg fabecd edfbag gefbd acbdeg | cedgf edbacgf fbag gdbea +bfc cfeabd gfaeb cgbfe fcdge efcagd bdcg bgadfce bc dcfgbe | cdgbfe gcbd cb cfb +gfbde fdgec efagcd ebcg ebd eb gdfba ecbfgd deabgcf becdfa | gcdfbea gecb febcgd gbce +acf cbgfad gabecd bcfd bdagfce aebgf fagcb cadgef dagbc cf | dbcf afgcedb edcfag cfbd +fbcag ec gacfeb efgc ecb gdfaebc aebdf gbecad dacfbg cafeb | ce cgfab cgdfba cbe +abdcgfe gfadce fcgbe fgadbc gcb gb debg gdecf bceaf bcdgfe | gb dgecfb gaefcd bcg +fdbca adbfe dabfgc ebcdaf efagb dcefga de becd dae bafcedg | cedabgf de de ed +ge bcgfa eacdgbf aegc efg cagfbd fgcbe dbfaeg aecgbf bcedf | ecga ecga gfe debfacg +geda gfaeb agcdebf agcfb cgfdbe ebcadf gfe fbdeag efdba ge | dgea egad eg aegd +bgfecd cdegb ecgdba bagce eag dcfegab dfceag ae cbagf bdae | fdbecg abcfg gbcfa ae +adfbc fdbaeg bce bcaegd gbdcfea adceb ec dcegbf aceg daegb | ce dgbaefc bdcae fgcdbae +faedb bef fdcbae cfbd ecgadfb bf gabefc fegad bcdgae edbca | bf cebdfag ebdfca fb +badfg acdfgb dbgae fegbdc agfe afcedgb aebcd eg edg egfadb | eafg eg gdcbaf cdabfg +gacdf cegfd acdegf dbgfec ad fbgac dgfaecb dgea bafced afd | agbdefc agde ad da +cfbdg fcadgb fbg gcab fbcde gb degbfa dcfag edgcaf cdbgfae | fdbcaeg bagc bdegaf cfdbg +fgeab abegc afdecb cdgbef fg gfda beadf gdefab bdaefgc gef | feg fg bgfcde dfga +fgcab becdfg dfec dcabeg daebgf gbfcd fd dgebc ebcfdga dfg | eadfbg edfc ecdgb fecd +gfcd fbaeg df begdf fdb gcedb adbgec fdcbge cbfdea acfgbed | gbcaed cbged degfcba dfb +adgfb eagf bfade dgbaef bcdgf dga bcfdae ag gecadb edbgfca | ga abgefd ga geaf +cdg bfcdeg dagbc dc eacgb ceafdbg abgfd gefabd cfdbag cadf | bdacg gcd acdf dcfa +caefd dg efbgca gfaebdc bdeacg acegd debg fdcbag cbeag adg | fdcea gd degb dag +gfd cfbeag dabfe dgce dbfge fbgce cfagdb bcgefd bgecadf gd | gd ecgd dfbea cfedagb +cgabe dbefga egdfbac bdcfe acgd ebcdg gbaecd gdb dg ecgafb | dagc badfegc dgac gdb +ebfc cf cbdaf bdacef acdbg dbeaf dbecagf gadfce abgedf cfa | caf dcfeba debfca ecgdfa +gc cadeb cbfedg egabf ebacg badgce gfbadec ecg defbac gcad | cbgdae cagd ecagbdf cgedafb +eadgb cgdeafb df aefdg ebcafd cdgbea dagfeb acfeg dfa bdfg | agcef bfagedc gacfe fd +cbafeg gedcf fdgecb fc cfg gebdf bgfeda bcdf caged bcefdga | cbdf fecdg bgedfa bcaefg +bafcg ba fadbcg dacb fab bafdge becgf fdcga gafdbec efcgda | afb gfabcd bgfca ba +dfbgae egbc cfadbe dbeagc ec ace ecgafbd edgba afcgd adegc | dgefba dfcga aecbdf ebgc +caeg fdbcg decbfa dbefag gbadcfe gef gefacd cfegd ge aefdc | edgacf fdegc cfged egf +fad fedbg dagbc dafbcg gebadc afcb dgafce dafgb fa fdcebga | bgafd fabc fcbgaed edagbc +febdc fgde fgecbd ceg aefcgb ge bcadg dbegc faebcd gdfbace | dcgafeb bcfdge dcfeab cge +edgfac bfagcd ageb bedaf ea fgabd gaebdfc fbecd aef gefabd | ae gcfedba ae fae +adgbfe fcbad fbgdec be efadg adfbe edgacf ebf debcagf egba | geab aefdb cdafb eb +ebgfa afbcd cedagbf aebdfc fbgad gbdfac gd defcgb acgd gdf | gd dgf dfg gd +facdeb egab ebdgac ecdab cadge eg bdagfce gcfbde gde acdgf | efabcd edgcfb dge bgea +cdbage bgdefac gacf dagec feadgc ecfda bdcef fa afe bfegad | fa bgcdea eaf cfgade +ebac dfegb dcb bdcfea cbfgda ecadf gecdbaf cfedb daecfg bc | gdefb gfcadbe facdbg aegcdbf +cfbead cbdagef egdc bdc bfegc dcbgf cd gabefc ebfdgc bdafg | fdcbg bcgedaf bcd efbgc +cfebg bgca fbgdae gefcd cefba dbeafc gbe bg afegbc gbafdec | bg bg ecbfa abcg +acgfed cbeaf dgbe gabecdf gbfdae fdeab adfcgb abd bd efgda | defab bdcgaf dgbe dbfgea +abfdc cdabef dbgfac fbcg gedac bg ebgdfa gab gbdca fagbedc | gb cbgf fdcbea abg +ecdafg abcg dgb gb bdefgc bagcde degac adfeb egdab cgbdefa | baged eadbf bg gfecda +cbge eb egfab efdacg bfagec agdbf cedabf gbadecf abe cefag | afbcegd gebc abe abe +fbgaec eg bgdfea gcbfda bdcefga fbdce caeg abgfc gef ecgbf | cafbg acbegfd eg cfabg +caf bafgd bfgec baec ac dgceaf fbagce badfceg ebdcfg cgfab | bagfd bagdf cdbagfe cfa +egdac edbcgfa acbefd bfgea agfebd abceg febgac bc ebc bfgc | cbe bgcf cgaeb cegba +fc acbdef fdbae fgeabdc dbcef gefdba bcf efacgb gcdeb cfad | efdab eafbd cafdbeg fc +aegfcdb gfceab cegadb gfedb gbaec fa bfa fcga dcbfea efgba | baf gcadbef bfa dbgfe +gfacbd gcbafed edcbfa bd acdfg abd daecfg agbfe bafgd bdgc | agcdbf bgdc cdgb bda +fegdb afd bfgdae aebfd gaecfd gdab da baecf dbgcfe dbgacfe | dfbega abgd dfecbag gfdeb +cf dabce bedcaf fca beafcdg gdecaf cfbea afgeb decgab dcbf | eacfdb acbef cfa bdcf +aegcfb gadfec bgfce bfdae fac gacb ca abcgefd edbcfg febca | cagefb fca ac fegbdc +de dbfcega dbecga deg dcbe afcbgd bcgda efcadg gdaeb ebagf | gaebcd gde bcde bcde +dbgaf gae cdgbfa gafbced acgfde abef cgdeb gdefba ae dgeab | bcdge cfbaegd ebadg feba +bde dgea dcgbf fbdge de dafgbe efbag bfeadc fecabg fdbagce | de dbe feabdgc gdae +agdec bdgec gecafbd bcedfg ad fgbacd dbae degbac caegf adg | fecga adg gcdebfa cefgadb +bceadg ag cafgbde fedbg gab dbcfag ceabd agbed gaec befcda | ga ag gace agdbcf +aecdbg agbef abc becfagd agfcb ca cfbdg fadc dgcabf bcdgef | ca fbdegc dcaf gcfab +cedg agfedcb fecagb baedf ebagdc ec bec dagcfb eabcd dcagb | bce gdec cdge bagdc +fgdca cg cdgbef gdbfa cbag fdeac adfbcg cdg ebcgdaf eabdgf | cdg gbafd gc cabdegf +gdbc bacfge dfbeca gc gcf febcd gfade cfedbag fdgec bdefcg | cgbd edgfa cbdg afged +feb cefag fdabc ecgb gdeabf cfgdae facbe eb becafg dgbcfea | egfdac acfdeg dgecfba fcdab +faedgc aecdb afcb defgbac bae eadbcf fabged fedca degbc ab | ba fadce gadecbf ba +edfg egfcdb eg dfecb geb cbgaf dcgaeb acbedf cfbge fadbcge | ge befgdca fcebd cfgeb +fcagdb ebdcgfa fdaebc gafce gebcad fab fb cabfg bcgda gfdb | fba caefbd fb gfcab +cfegbad gcdabf cdgebf fe bgeac gdbeaf bgefa efda gfe agfdb | gebac ef agebdfc edaf +ecbdg aec febdca bgecaf eafd agdfcb cadgfbe edacb ea bafdc | efda cagefb defa aec +efagdb cfgbda gfdbcae edcbfa cadgb dg dag dgfc ebcag bcadf | dg cagdb gdabfc dag +dgcfeb dfebgca fbga afecd gaecb cfb bcafe eacbdg fb cfgeab | bf aecbg gbfa dgaceb +de dbcgfa fgdace acbdg abced gaebcd gebd fbcae afbgdce ced | edc gdbe bcdae fbagdec +gfdbce bgda dfcab abfgce cdfgbea dbf decaf gdcbaf bcfga db | bfedgc gcdbaf bd agdb +befacd bcdeg gfad begfa edfgba dbf debfg cbgafe fd fcebadg | fbecga dfegbca fd bfgaed +acgeb adebfcg febadg beafc aegcbd aef gcfe acgbfe acfbd ef | dbcefag afe bcega eaf +fcaegd bg dbagfc gbce gbedfc edbcfag bfged fcegd bdg fbade | dcbagef afecdbg ebcdafg gb +fbdcga da fdabcge fad dbag gbdecf gcafd gbcfd cdbafe aecfg | ad agdb dcfebg gadbfc +db bdg gadfc gdfcb dbecfg efdb gbeafc ebgfc gdcfaeb bacedg | gbd fgbdc dfgabce gadfc +bfeadg eafbcg fbage ed edfgac fed agcdebf dabe dgcbf fdebg | fcgdaeb fdebcga abfecg fgceba +cgfd eagdc afg afegbd faebc cdfega abegcd gdebfac fg gafce | afgebd gfa bedagf gfdc +efagd fgcbeda bfgac cegd cd edgafc fedgba bdecaf cda cfgda | dc cd aecbfd dfaebcg +edabf eacdb gcdfba fdbaeg ca gcbfdea cdbeg cad dfaceb ecaf | ca debfa cfedab baedc +ecafbg bd afdbce deb gedcbfa bfad cegad cgfdbe febac dbace | bed bde bd ecadg +bafgd agfbdec daegbf dgecb cbfgad adcbfe afeg dbfge ebf fe | dabfgc fbegd fe edcbfa +bdegf bd cedfg gecfda fbd fbaeg cefbdag acdfgb dbec dbfcge | bd bd cbaefdg fegab +dgfcae agd afbedg eagb daebf fgedbac afbedc dafgb fgbcd ag | fbeda aecbfd gbfcd fbadeg +ecgdfa cbgde bdafegc fg ebcfad fbace fbag egcbaf efg bfgce | gbefca ecfagb fagb cegdb +afgedcb fabce gae ecbag fedgba efcabg bdafce ge bcgad cefg | age gea egfc ega +fadgb fdgeabc bcefdg cdfeba fcdgb gbedc egcf cf baedcg dfc | dgcbf gafebcd cdf bfdaceg +ag gebdca dgbfc gefdcab fgcab eagfbc ecfab eacbfd faeg bga | bga ga gab bcfdgae +bdgcea gd gecd fcgadb gad egcba gcbaef eafdb dbaeg cfebgda | dbacgf dceg gdfecab gd +bgdcfe bda adbec edfacbg ad dgca bcefa becdg dacegb badgef | da adb egbafdc adb +ebafd fbgcae begfadc fcgbed feabc cgfa bdegac cabge fc ecf | cfe fgebac gedcafb cf +gcf badecgf fg bcefgd fbgac aegbc afgd acbdf bcdeaf gdfabc | gcf abcfdg fg cbfad +dbgace afcgdbe fdce baefd gbcaf abcdf dc bdc dfceba efagbd | dc dc acgfb cd +bdafegc cb becg becadg abc edbca dfabgc beadf ecdafg edgca | dbfcage ebdaf bca bdeac +bfdacg degf ef abcde fgdac cgafde aef cfead abcgfe edgafbc | efa fcbgae dfeg bgacfd +dcafbge aedbc abdcge gebac dabg gb cbg daecbf cgfae cgdebf | cbg agdb aefcbd agceb +cfgaed ec fcdgbe egdba gdfac becadfg dacge feac dec bagfcd | ce ecd egfadc gdeca +gbdcf ba ebacfg cagbd fadb gdeca bgfeadc bfdcga cbdegf bga | ba dfab ab ecbdgf +gdcabf bcfde cfdea dca eafdbcg ecagf ad gcefda bacfeg aegd | dca acd afcgebd efacg +ebafc egfb ecb be gcbfea cfegad fbcda dbfgaec gceaf ceabdg | abcdf gbef ceb ceb +decbf ecdbga adbce bac gfacbe ab aecgd badg fdbagce eafdgc | ecabgf ba dcaegb cfebag +fcbdga be gfbca cbeafd bgfea bagcef aeb bcge defgcba faged | aeb bea ebgc be +cgb abgcdfe afcb bc aedbfg gfcbd gdecf fdbag fagbcd dgeabc | efabgcd bdgfc debcgaf ebcfgda +cdafeg bgfedc edabc bdgea ac defcbga abfc dac abecfd bdecf | dbeag afbc abfc ca +egd efgbac cadgefb edafg gd dfbgea gfbd eabgf dagbce dfcae | fcaed cgbfea dfbg bagefc +abc fgaecb fedba cebgdfa gacdf aecfdg abgfcd bdgc fbcad cb | fecadg cbgd dfceag fcgead +bdec cgb abefcg bgdcf bc fgacbde gdeafc dbegfc fgbda gcedf | afgdb gecfadb cbegaf cb +dfeg gcadef fcega cbade fbcaeg defac fd afd afdegcb abfcdg | fad gafce badec afdegcb +gdbea ec becag ebc bgefcd ecad ceabdfg gbafc aegdbc defgba | bce gdecfb ceda ec +efcbag dcagfe cde ecgfd dgefb efgdacb gbdcae cfgea dafc cd | cdfa fdac agfcebd fcdgea +bgacde fgdc bfdcge afgcdeb acbfe gf gef ecdgb dabgef cebfg | cfdg bfcea aegdcb gef +gfcea agfd dfe cdgfea fedgc egcbaf df fdacbge cebfad cgbde | edcfab dfgcae dfga df +ebga egacdb fdagbc dabcg aec dcgfae bdaec gfbdcae ae cefbd | gaeb dcaeb eabg acfgebd +aecfdb agcdb facgb bged fecbadg adbgec bd cdgae eacgdf bcd | dcbeafg cfedabg egdb degb +aedb cfaebg adegfb gbafd da debcagf facged dgcbf afd faegb | ad bdae bfeag aedb +beagfc fcagd fbcgd egdacb efgacd fead acefdgb dgaec acf af | fagdc dfae fagecb dcgfb +bacd gcaeb agd begdf bgdea gdbaec fcageb cegdfa afebdgc ad | egdab edgcfa ad bgcafed +degacfb dfgab ae cgbde ebgad eda cebdaf gafe fabcgd aegbdf | gafe aebgd ae baegd +fdaebcg cegadf ecag gdcfb fedca dabfeg ge aefbcd fge dfcge | edfca fge egf agec +dgebaf cafeb ga cbfeda fgbac ecagfb bgdcf gfa cgae facgdbe | gecafb cfdgb agf gfa +fdageb bfcd gdeca eagfcb cbfaed bd ebd beacf gbcafed dbcae | bfeac ecdag fbdc fdcb +ebfd cfe cbaed bfcag dfagbce ef dbaefc ecafb eacgbd fadceg | abcfed cfbga fec efc +gfe gfbac ef fdce edcgab aegfdc bgcdaef dagec fgcea afdebg | ebdgac gacfe efg feg +efdgac afd cabdeg defb df cgfab badec dfcbgea fabdc fbadec | badce efbd deacb daf +fg cfdg fga ebafgc cdebag fbgdcae aebfd faegd adgefc daceg | gf fga defba gf +fecabd cfadbg cdebgf gfdcb bedcg eb gdeca begf ceb dfaecgb | egbf cbefdg gcfeabd bgfaecd +gf fbegd bcfg gcbde dcefga aecgbd ebcdfg bdegfac dgf bedaf | bedgfc fg dfg eadbfcg +edfcga efbcad eba dabceg ba dfbeg agfcdbe dface eabfd bcfa | dgeacb ebdcagf ba facb +cbgead beagf dbcge fdcebag fecbg dbfgca gfc efdc dfbecg cf | fcg decgab efdc cf +dfbgc caf abecfgd dcea edafgb ca gfdae acbgef acfgd cafdeg | aegfcdb adec agedcf ca +fe edbgac fagcdbe egdbc aedfcg edcfb dfe cdbfge dcbfa ebfg | edbcg gadfec bdacf fde +bag dgefb eafg eabdg bfdcag cebdfg ga dgfabce agbedf ecbda | gfea bag fdgeab ga +dcegf bcfega bcadfeg gfdeb fbg cfgaed becdgf fb dbfc agbde | dagecfb bdfc fcgeda bceagfd +ecgdba cefdba bacfgd bcdeagf gd degbc gbcfe eadg ebadc gdc | cebgda efcbg edag dgecb +dbeafc cgbd cfb cfegd cb edfacg bcgfe gabef adgcebf edcgbf | abcfdge fbc bc efgcb +gcefda fgba fa eaf beadc fgbade gdebfc dfgbe fgdcbae fabed | defbg dcefagb af aebdc +fdaec gbfadc bedgfca egfdc gdcfae gd cebdfa ecbgf dgf geda | gdf cfadbg acebfd fcaegd +gdbefa ecdfg dgeabc gfabce dbaeg cbg bc cedgb cabd cadgefb | bc cfedg edfabg geabd +gba dafgcbe edabcg fdcabe gcfbe abdegf aebgf fdabe ag afgd | befcda fecgadb cgebad dfga +dafgeb cgde cfadegb agfec gcafb cafed cagefd ge dcaebf eag | fgace cbefad eafcg ge +dfabegc cabedf cbe fced dbeacg ebfda bdfeag ec bgcaf fcabe | ecb fecd cgaedb ebdfa +ecf fedabc afcdg fdbcag efgdcab cbega fdge fe feagcd fegac | gafce cfe cdgabf gacefd +fabeg gdf gcfabed gbaefc dg dgabef degb gfbad egdcaf acdfb | defgca dgf caefbdg begfa +eabfgd edfab ebcfag egdafbc afd edfg fageb df fgdbca acebd | gbfea dbfgea aebfgdc dcgfba +cg dfecb cegdb dgbceaf dfcg bgfdce fbaceg dabeg egc bdfcea | edgab cg ecg gec +db dceag abecgf bdc bfegc beacdf gbdf bcedg bfacgde efbcdg | gbced bdacfge fcgeab fgbd +gfecd gdeacb cdfaebg bgf dfebg fabd fb gdbae gefabc bdeagf | bagde bfg egcfd bf +fc dbagef bfedcag fcda ebcgd fgdea dgefac efgabc defcg fce | afegcd facd eagfbdc fce +eacgb gfdaecb eafb egfdbc acgfb fb dcebag fbg fdcag abcfeg | beaf egabdc gbedcf gbf \ No newline at end of file diff --git a/src/day08.rs b/src/day08.rs new file mode 100644 index 0000000..02f0f28 --- /dev/null +++ b/src/day08.rs @@ -0,0 +1,109 @@ +use crate::Day; + +pub struct Day08(Vec<(Vec, Vec)>); + +impl Day for Day08 { + fn init(content: String) -> anyhow::Result { + let x = content.lines().map(foo).collect::, Vec)>>(); + Ok(Self(x)) + } + + fn part1(&self) -> anyhow::Result { + let mut count = 0; + for (_, b) in &self.0 { + let l = b.iter().map(String::len).filter(|n| (*n == 2) || (*n == 4) || (*n == 3) | (*n == 7)).count(); + count += l; + } + + Ok(format!("{}", count)) + } + + fn part2(&self) -> anyhow::Result { + Ok(format!("{}", self.0.iter().cloned().map(do_stuff).collect::>>()?.iter().sum::())) + } +} + +fn do_stuff((input, output): (Vec, Vec)) -> anyhow::Result { + let out = output.iter().map(|x| get_char(&input, x.clone())).collect::>>()?.join(""); + + out.parse().map_err(anyhow::Error::new) +} + +fn get_char(input: &[String], s: String) -> anyhow::Result { + let one = input.iter().cloned().find(|x| x.len() == 2).ok_or_else(|| anyhow::Error::msg("could not find one"))?.chars().collect::>(); + let four = input.iter().cloned().find(|x| x.len() == 4).ok_or_else(|| anyhow::Error::msg("could not find one"))?.chars().collect::>(); + let chars = s.chars().collect::>(); + let x = match s.len() { + 2 => "1", + 3 => "7", + 4 => "4", + 5 => match chars.iter().filter(|x| !one.contains(*x)).count() { + 3 => "3", + _ => match chars.iter().filter(|x| !four.contains(*x)).count() { + 3 => "2", + _ => "5", + } + }, + 6 => match chars.iter().filter(|x| !one.contains(*x)).count() { + 5 => "6", + _ => match chars.iter().filter(|x| !four.contains(*x)).count() { + 2 => "9", + _ => "0", + } + } + _ => "8", + }; + Ok(x.to_string()) +} + +fn foo(st: &str) -> (Vec, Vec) { + let z = st.split('|').collect::>(); + let input = z[0]; + let output = z[1]; + (input.split_whitespace().map(String::from).collect(), output.split_whitespace().map(String::from).collect()) +} + +#[cfg(test)] +mod tests{ + use crate::Day08; + use crate::day::Day; + + const INPUT: &str = r"be cfbegad cbdgef fgaecd cgeb fdcge agebfd fecdb fabcd edb | fdgacbe cefdb cefbgd gcbe +edbfga begcd cbg gc gcadebf fbgde acbgfd abcde gfcbed gfec | fcgedb cgb dgebacf gc +fgaebd cg bdaec gdafb agbcfd gdcbef bgcad gfac gcb cdgabef | cg cg fdcagb cbg +fbegcd cbd adcefb dageb afcb bc aefdc ecdab fgdeca fcdbega | efabcd cedba gadfec cb +aecbfdg fbg gf bafeg dbefa fcge gcbea fcaegb dgceab fcbdga | gecf egdcabf bgf bfgea +fgeab ca afcebg bdacfeg cfaedg gcfdb baec bfadeg bafgc acf | gebdcfa ecba ca fadegcb +dbcfg fgd bdegcaf fgec aegbdf ecdfab fbedc dacgb gdcebf gf | cefg dcbef fcge gbcadfe +bdfegc cbegaf gecbf dfcage bdacg ed bedf ced adcbefg gebcd | ed bcgafe cdgba cbgef +egadfb cdbfeg cegd fecab cgb gbdefca cg fgcdab egfdb bfceg | gbdfcae bgc cg cgb +gcafb gcf dcaebfg ecagb gf abcdeg gaef cafbge fdbac fegbdc | fgae cfgab fg bagce"; + + #[test] + fn part1_test() -> anyhow::Result<()>{ + let d = Day08::init(INPUT.to_string())?; + assert_eq!("26", d.part1()?); + Ok(()) + } + + #[test] + fn part2_test() -> anyhow::Result<()>{ + let d = Day08::init(INPUT.to_string())?; + assert_eq!("61229", d.part2()?); + Ok(()) + } + + #[test] + fn part1_real() -> anyhow::Result<()> { + let d = Day08::init(crate::load_input("08")?)?; + assert_eq!("479", d.part1()?); + Ok(()) + } + + #[test] + fn part2_real() -> anyhow::Result<()> { + let d = Day08::init(crate::load_input("08")?)?; + assert_eq!("1041746", d.part2()?); + Ok(()) + } +} \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index f0b97c6..c8d3476 100644 --- a/src/main.rs +++ b/src/main.rs @@ -10,6 +10,7 @@ use crate::day06::Day06; use crate::day07::Day07; use crate::day::Day; use anyhow::Result; +use crate::day08::Day08; mod day; mod day01; @@ -19,6 +20,7 @@ mod day04; mod day05; mod day06; mod day07; +mod day08; fn load_input(day: &str) -> Result { read_to_string(format!("./input/day{}", day)).map_err(|x| x.into()) @@ -60,7 +62,8 @@ fn main() -> anyhow::Result<()> { Box::new(Day04::init(load_input("04")?)?), Box::new(Day05::init(load_input("05")?)?), Box::new(Day06::init(load_input("06")?)?), - Box::new(Day07::init(load_input("07")?)?)]; + Box::new(Day07::init(load_input("07")?)?), + Box::new(Day08::init(load_input("08")?)?)]; let _verbosity = matches.occurrences_of("v"); if matches.is_present("all") {