From 1fc3c1632d9568c5a4d44e321e08719015ecf157 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20Capelle?= Date: Sun, 10 Dec 2023 20:23:22 +0100 Subject: [PATCH] 2021 day 8. --- 2021/day8.py | 82 +++++++++++++++++- 2021/inputs/day8.txt | 200 +++++++++++++++++++++++++++++++++++++++++++ 2021/tests/day8.txt | 10 +++ 3 files changed, 288 insertions(+), 4 deletions(-) diff --git a/2021/day8.py b/2021/day8.py index 992bf35..1560410 100644 --- a/2021/day8.py +++ b/2021/day8.py @@ -1,13 +1,87 @@ +import itertools +import os import sys -from collections import defaultdict -from dataclasses import dataclass + +VERBOSE = os.getenv("AOC_VERBOSE") == "True" + +digits = { + "abcefg": 0, + "cf": 1, + "acdeg": 2, + "acdfg": 3, + "bcdf": 4, + "abdfg": 5, + "abdefg": 6, + "acf": 7, + "abcdefg": 8, + "abcdfg": 9, +} lines = sys.stdin.read().splitlines() # part 1 -answer_1 = ... +lengths = {len(k) for k, v in digits.items() if v in (1, 4, 7, 8)} +answer_1 = sum( + len(p) in lengths for line in lines for p in line.split("|")[1].strip().split() +) print(f"answer 1 is {answer_1}") # part 2 -answer_2 = ... +values: list[int] = [] + +for line in lines: + parts = line.split("|") + broken_digits = sorted(parts[0].strip().split(), key=len) + + per_length = { + k: list(v) + for k, v in itertools.groupby(sorted(broken_digits, key=len), key=len) + } + + # a can be found immediately + a = next(u for u in per_length[3][0] if u not in per_length[2][0]) + + # c and f have only two possible values corresponding to the single entry of + # length 2 + cf = list(per_length[2][0]) + + # the only digit of length 4 contains bcdf, so we can deduce bd by removing cf + bd = [u for u in per_length[4][0] if u not in cf] + + # the 3 digits of length 5 have a, d and g in common + adg = [u for u in per_length[5][0] if all(u in pe for pe in per_length[5][1:])] + + # we can remove a + dg = [u for u in adg if u != a] + + # we can deduce d and g + d = next(u for u in dg if u in bd) + g = next(u for u in dg if u != d) + + # then b + b = next(u for u in bd if u != d) + + # f is in the three 6-length digits, while c is only in 2 + f = next(u for u in cf if all(u in p for p in per_length[6])) + + # c is not f + c = next(u for u in cf if u != f) + + # e is the last one + e = next(u for u in "abcdefg" if u not in {a, b, c, d, f, g}) + + mapping = dict(zip((a, b, c, d, e, f, g), "abcdefg")) + + value = 0 + for number in parts[1].strip().split(): + digit = "".join(sorted(mapping[c] for c in number)) + value = 10 * value + digits[digit] + + if VERBOSE: + print(value) + + values.append(value) + + +answer_2 = sum(values) print(f"answer 2 is {answer_2}") diff --git a/2021/inputs/day8.txt b/2021/inputs/day8.txt index e69de29..fd3d8ec 100644 --- a/2021/inputs/day8.txt +++ b/2021/inputs/day8.txt @@ -0,0 +1,200 @@ +caebgd dagc eabgd aebfgc fbdacge edg dg dbgcef eabfd cgeba | gbcdae dagc acgd gd +fgcbed bcedga cafb acgfd cgabd cgf dfaeg dfbcga bceagdf fc | cf gdfea fdagbc dfacg +gaed egcbdf edagcf fcaegdb facge afg ga ecbaf fgced fgdabc | cgeaf gfa ga efbac +cbdeg cbgeadf cgdfa cgdbae decgf efg cebf egbfdc fgbead ef | fge gfe dcegabf gdcfe +bacd cgdbe ecgbf cd cde degba cfaegd gfadbe gbdace baegcdf | cfgdea dce bacd cabd +gdbafc cedagb cebga bc edcb gbdefa cebgdaf agfce acb bgdae | afgedb bdce dabeg dbec +fadce bad edafbc cgbfa edcagf dacbge dfabc bgecadf edbf bd | efbd baegdc dab db +fcaed eb afcdge cfbae gacbf edab becgdaf gcedbf efb bdecaf | be gadbfec eb cedfa +cdgbea ebcga feacb age ge afcdgb faegdc acbgd agcfdbe bdeg | gedcab dcagb gea edbg +eda bgeaf eabdcg ad ebgdacf egdfac ecdbfg dcfge acdf dagfe | ad ad da beagf +cegfa bf ecfabd fgcb egcafd ebfga bgade afb eagbfc dgfbeca | bcegaf fcgb adgbe bcgf +fegacb dbagc gdcae fbcd bc dfbgca gdbfa cgb adefbg ecdabgf | cgb fbgdac cabfdg acdeg +gfbead cfbgea cfeb bf agcfb baf cdgaf begacd aebcg acgdfbe | fab gdcbeaf afcbeg bfa +df acgbf bedag gecbdf dgefacb fdagb gfadeb fbd abgecd efad | bcafg cafdgeb bdf fd +defbc dg gadc caebdfg bceagf gecba adegbf ebagdc gecdb dbg | bfgdea aefbdcg dgb dbceg +cegbd cafegb gedcab gcebdf ecdf dfbag fbgde ef efg fbaecgd | fedc ef fdec ebagcf +dbfag gabdcf dfgbeac efdcag gbcfe ed efbadg efd bade efbgd | bagfd def ed efgbda +gafbcde gfbdc fc geafbc cgf ecdfgb cfde dbgac gdfeb gedabf | fced gfc cdbag gfc +ef adbefg efdbc cfabd fcea fbe cebdg cbfgda abecfd dagbefc | degcbaf ef fecdagb dafebc +acdbf abefgd ea dgcfe acedgf agec faedcgb afe gcbdfe fecad | geca gebadfc fgeabcd efdca +agfecd acbg aefdb bg gdcfa gdafb cebdagf gfb dgcafb cgbefd | fbg dgafc fbg bafdg +db ebafd dcafeg bcedag eafgb bcdf ecafd adb eabdfc cdbgaef | bgafe dfbea bd daefc +egfacd cegfa afbdg facgbe de dfegbc cdae edafg egd ecdfbga | edg defcga aegfc de +abdgfce begca egcbf ag gdafbc afge fbdcge daecb cefabg cag | gbfced ga cgedbfa ag +faed abcedf eafdbcg aebcf cbagf cgebda ef fbe cbgfde bdcae | afbcg dafe fbe fbe +bcea cfdae dcafeb ab cfbdg dgeabf afbcd baf fdacge gacfdbe | baf decgfab fab abce +dbeacg agefcd agbefdc cagfe ae aeg aedf gdafc bfceg bacdfg | gea begcf fdcage ea +cagdeb ca bcfgad badgef cbaf cgbefad adc fcdga gdfec bfagd | aecbdfg afcb ac bcfa +bc begda gebfcad bfcd dbeac abdfce dcafe cbe cafdge bgcfae | bcdf ebdga gbfecda bce +dfacgb edbcg gfedab egfab bac begac fcea ca dgfcabe ebacfg | bac cba bgcde ca +fgacbe dgeba agebf afb fbcaed eafcgd fb dfegacb bgfc cfgea | cfegabd ceafg bf cbadef +fgcab ceabdgf fdabc da gdabcf gdcaeb ecfbag fadg cdbef acd | fagd gfad fcbgae adgf +afbgecd cedga cdfb ebgdcf gbfade bcfeag cedgb efgbc bd gdb | fedbcg cefdbg edcag dgb +bfcga gfadb egcadf cbeagfd bdfeag bcfegd bd edgaf dbae dfb | bfgadec dfb bfd cbfga +cbegad bacde eafdb bcgea cad cfgadb cd gced fgedcab bfecag | fdgbeac eacbdfg acdbe abdfe +cebaf dcegbaf edfgab cabgfe bafeg cgaf aegbdc cea febdc ca | ac ac ca cfga +db bfd ecdfg febdc debfac egdfab cadb efgacb defacgb bcfae | edbcagf bd debfac fdb +egfdcab dcgbe dacgef fbad bafcge ab degfa ebfgad gbdea gab | ba fabgecd ab agedbf +afbc efadc efcgabd dfbeac ac bdgeac cfgbed afgde cfdbe dac | ac fegcdb afedc facb +acbde cgfdea cdbge cfbdea abd ab gacbdfe fdcgab acefd fabe | fbae dagefbc aefbcgd dba +cedbfga dabecf afbge fab ecbfdg gedfba fbgde cbeag dfag af | beafg acbfed fa gdaf +ecbgfa eab agdfebc adbg gdfbe dfgecb dabfe afced bagfde ab | bdag gdba dfbge gbda +egfdac eadbg gfdab bcdega ae egabdfc cdfbeg dae gcbed bace | dgbefc gadefc ea eacb +bgacf dgfcea cbfgeda fdab fa fag fbgadc gcbef cdabeg bcgda | gfa fag afg aedcbg +egafdcb dcega dgfbc egdbaf ebdcg dbe eb cabdeg ceab fcdaeg | bed edcfag gadefc fcdbg +dgcab afgb bcg dcaeb dbgcaf bg ecfdgba gafced fbcdeg cfdga | cefgdb gacfbed afdgc gbcdfa +cgeda bafcg cgdfa dgfcae bceagd bdgface adf fd feabcd efdg | edfg gdeca cgbdfae dcfgaeb +dbefga eadcgb gbaedcf daebc geadc bd bcgd bafec bad gaecfd | edagc abcef fceba aecdg +bcegf cfbega bgedca befca gabecdf bgc gfca gebdf cg dcfabe | efdbg bcg acgf fecbadg +gfcdeba dbaec ecgaf gde agedfb bcafeg gdfc dgeac dg cadefg | egfca fegac edg daebgf +bea geadbf be efcad afecgb adfcbg cbefa fcabg gecb egbdfca | eab cbfae gbcafed cbeadgf +adgfec bgea fbcdg be fdceba bgedc edb acged bfdceag dgbcea | decfba efcdba gbdface aedgfc +ebgfc dcb dc ecfd fecbgd debcg bgfacd defcgab bacgef dgabe | dc adfbceg befgc cfed +cbgdea gafc fcegd eagdfb bfdce egc efdag gdafec cg gfbceda | cg ceg dgfea cg +fgdab egacbfd decgaf eaf edcfgb ea efdcb aefcbd eadbf abec | fdbea ea acefdb ea +bdegcf aegfb eacd ec acfgd gfdeca fce adcfbg begafdc gcaef | acde gbefcd adce fec +cdgfbe fdacg cegdf cebd cbeafdg efgcb aegcbf bgfead efd de | fcegdba cbde gbcadfe fed +adfge efgbda gacfde gecfba ce feacd adbfc cgde fce dfabgce | fgcaed cgde gfaced fdeac +ga cgaefdb dcebfg fbegac gbda acdef cdgeb gbaedc ecadg cag | bagd bgfdce cbgde dbfaecg +gec efdabg bfgdcae dfebc agbc aefbg afgbce agecfd cg cegbf | acfdgbe cbdef abcg afbedcg +ebcgaf cagdf afbdeg fbcda dcfbeag beacfd befca bfd bd cebd | dfb dbf feacbg gfdaecb +ecgdfa afe gbafd bfgdac ae decbf dgebaf afbed abeg cedabfg | egab cgeabfd eadgbfc ebag +agcfdeb fdabe gfcaeb edf cegfad badce gdbf fd gbafe fedbga | efd bfgd daecgfb cabefg +bcdef gefcadb fdeba fdega ba bgea bgdafc efbagd dfcgae dba | ba ba edafb ebga +acgbe age ga agebfd afcebg bdegc acfeb fgca cefdba cabegdf | ag eag afgc ag +bacfd feb gfea dabge fegadbc adegbf fe aefdb cbdgae gdcbfe | ef ebdfcg fgdeba efb +efgca fadbc daecgf ecbfgd gd daeg dfcagbe agfdc bafecg dgf | fgd cfeagb afegc dfg +cgeabd cdagf dfab afcbgd dceafbg adgbc cfd df efdgcb afgec | cdf cfabdg abfd df +bgacef acegf adgce cgbfaed dgbec gcdefa afed ad badcgf cda | ad egadc degbfac efcagd +de ceafb bfedacg decf cbeda aed gdefab dfacbe gadcb gecbfa | acefb eda edcf ead +fdebga dgbcef baf af caefb debcf baecg cgdfaeb dafc facdbe | af fdac fgceadb efcba +dgbfac cabdefg ag gda dgcbf gafdb dfaeb bedgcf cafg adcebg | fgadb egfbcad fgca gfbda +egcbfda fagbde cb egbcf fbc dcgb cdbafe fgdbe dcefbg ceafg | bfc gfcebda bcf bcf +cfeba ag fecag feacgb eag defgc egabfd gbcafed agcb bdacef | gcfabe efcadgb ga gabc +fgeadb gbfdace feacb ed bacfde fdbcg edca ecbdf cebgfa def | ebcfa acebdgf efd aced +fcgad aegfdb ea bdfcea dea egfbd aebg cgbedaf begfdc fedag | geba egbfd fdagbe dcbaef +faebdg efbca fadce bgefa fcbgae dbecfag bgcf cb ecb dgaecb | cadebgf ecb gcfb cb +ecdf begca cbagfd ed edb dfebacg cdgfb bcedg cgbfed edagbf | de dfce gedcbf de +badfec dfgcab gdbeafc cbf defc acefb ebdgaf cf abedf egacb | cdfe cdef fedc fc +afcgbd fdcg fbc bgdac acbgef cf fcabd gdebca fbaed fcdageb | cf fbc cf gfcd +cefba dbef fe gdafec dbcae fdebac bfadcge fec gceabd abcfg | gacedb debac bcaed gacfdbe +bagfe db bdf gafdc bfgda cgefbd cafedg fcgabd fdeacbg dacb | gabdf cdgbfa bd egfbdc +dbcaef bacfd begfcd gbafc cedbf da eabd gecdfa cda fbecgda | aedb cda efcdb adcfbe +faebgd afcbdg gf dbacfeg gdf degfa dcfea gebda dgaceb gfbe | bgfe decaf gf edgfa +fg aecgbfd ebcfa efabg adgeb fge egcbdf bedagf dbcaeg fagd | fg dfga gfda gafd +cedgabf dcba ab cedaf bae cabefd fgaced fdaeb fabgec dfgeb | bedfac ab fecbga debfcag +dec ce fcabde daefb fgabde aefc bdagc dcgfeb efcdabg caedb | gadbfec ecfa baefgd ce +egcaf ed adbe afbcd dgfecba acbdgf edf decfab edcaf egbcfd | dgecfab eabdfcg fbdaec abed +fea febcg eacgf ecda cdgfa agcedfb edgfba ae agcfde cbadgf | fcegb fgbaced dcafg caed +gebfd ec dec eabc bafcged debgc fecgda fdgabc dcgabe cgadb | adegbcf gbacfed bfgcdea ce +egfdab cad bcgad cd bcfga gfdbcea dgcaeb cedg defbac beagd | cadbfe decg cd cadfeb +cge gadebfc fbcgae gc dagec agdeb dcefga cgdf afbecd ecfda | ebgcaf dbeag fgcdbae dgcf +bdegca ecbdaf bfae cgdfb ebafdgc ba dfabc bac feagcd fdcea | bac ebcfadg ba ab +gceda eab agbfedc eafcdg ab gbac bgdef gacbed dgbea cfaebd | bgfcade ba abgc bae +gbfe eg gcfdeb daebcg bcdef cgefd cdfag fbdeac egcadfb gec | ge befgdc gce egc +bga gbeacd cbgde gdefcab cagbdf ab beda cfbegd aecgf agecb | agfce daeb bead agb +fedgba agecbf bc bcdf cgb febdcg ecgfabd gcade dgbec efgdb | bgedfac cb bc bc +gfaeb bcdfe cea gfca bdacge aecbdfg fegbca ac dfgbae caefb | cfga agcf cfga cbgade +cgeab fbegda adb dagbfec eafgbc bd bgcd adecf cegdba daebc | efbcdag gdcb bd deacfgb +bcagd cbgde gbfad eabdgf cda ceabfd fcag cdgabf agcbdfe ca | ca ca ac cda +agdce dageb eacdbf ecgdaf bafgd dgfacbe dgbaec bceg bea be | gceb bgdcaef edgac aedgc +bceadf adcfeg ga dfag geacd cabegdf ceafgb gca aecfd edcbg | ag acbfde gdfa ag +fdcegb abdfce cdega bgcad gfea cae ae bcafged fagedc fgdec | gfdce bafcde gfcdeb ae +egbcda cebadf bfe ef bedcg bgfda fgec fedbg begcfad gdbcef | bef gcbeda ef ecgf +egfdb cgd gdbfea cgbdf fdcba fgbdaec agbdec cg fecg cgdbfe | abgfedc fbcgd cegf gc +cfbegd ab gbacfd agefd ceab baf acfgdeb eafbgc bfegc bagef | ba abf beca baf +fcega fecda cbgaef fgaedb gbfc geadbc fag ecbdgaf eacgb fg | ecdfa bfgc dgebaf gcabe +aefdcg gfdcab ab fagb dbaegcf adb faecbd gcadb fcgad ebdgc | gadcef bfdaecg fgba fgecad +eabfc cdebf bgfca ecfbgad fbdceg aeb gceabd afde ea cbfade | abcdgef eabfc abe bdcfae +cd dgfceab dec cbegfd gedaf adfgec ecbag fgadbe cadf cgdea | fgedbc edc dce adcgfeb +agcdbf ecdgf adfcg agfcbed ef ecdfab efc agfe cgebd defagc | eadcfb cfdbega cef geaf +cdbafe deacf ga dbecag fecdagb bcfge gfda caedfg gae eagfc | ga eag gfcebad cfgae +ceadfg bdf gfbec adbe fbegd abgdfc bd gdefa gdfeba dgacefb | bagedfc facedgb fbd bd +ecdba ecdagb gcfeda fbdaeg cfedb befcdag ca agedb abcg ace | cea fbaged eca bcag +gfedc gdaf gaefc dcf bgcde gdeafc fcgadeb gecabf cdafbe df | fd gcaef df egfdca +afegb cefgb eadcbg cgfbad dbecg cfde aegbcdf fcb gdebfc fc | fbcged bcf gbced aefgdcb +ca bfeda cae ecdfgb edgcf dgceaf gbaced afcg gbeacdf aefcd | ac dfcebag cagf ace +begcad efdagb fbgeadc fedcba aec abedg fcegb ca cgda abegc | abcfgde fgebadc bagedf gdca +aegb cfeadb acdgf decgbf ecgdb gcfedab bgdcea ba gbdac bad | bgceda gdafc fgadc dafcbe +fgecba aec adfe deacb ae abegdcf bcdag ecbfd gecdbf dafceb | gdcab ae edfa daef +agfde eacg adebfg fdgcb cafdg fgdeca cfbaed ac gcadfbe acf | fca gdfae acge dbeacf +fbagce de deg edfa fcbdg gbdcae aegfb dbgfe dgacbfe gefbad | edfa de ged bdgcf +bacfdg cdeafgb aecbfd daefb agedc afc abdefg cebf deacf cf | gbdafc efbc cfead fc +cegfab cdag bdc dc febad gfdbce dcaefbg gfbac dcafbg cdabf | dgafcb cdag dcbgeaf gaefdbc +dagefb acefg afdcb gd dgfaecb facbgd bcdg gda badcfe fgacd | fbecgda cfadb gbdc fcaeg +gfbd cfeda gabcfe db dba baefg beafd bcgdae fedcbag efbdag | dba bad ebgaf dbegfca +cf fbdega aefbg afbcedg edgca dgbcfe gfaec febcag ecf afcb | aefbg gcaefb dbcegaf cef +gebdaf abgd cdabfe gacefbd agfed dg ged fegac aebfd fbdcge | egd abdegcf gadb afbgde +gcdf efdcb acfebd beagdc gd bdefg ebfcgd bdg fbega geabcfd | dgceba ecadgb adgfbce edbgf +fdcaebg efbdgc bgdacf dcae cbdge gebaf abd edgab da bgaedc | cebagd ad da gebcda +bfgcae cbd bcfea aedcb gbefcd cd adecfb adfc cagdfbe dbega | fcad cdabgfe dacf dcb +becg gfbace egacfbd acbfg acdfgb aec ce bdfea cgedaf fbcea | afcbg fedagc befac aecfgd +befa cgfed cfadb gdcfba acdfe ace edgbac fgcdbea ceafdb ae | feab eacdf bcdgafe bfae +bcdefag dafeg fgec dgeafc gea gdfbca cgdaeb bfdea eg dgafc | eg aefcdgb ecdfag gea +gfadb gedfb bdecgfa adbefg dcgaf abf gdcefb aebg ab bafced | gdbfe gbfed ebag cabgfde +dbegfa acgbdf eg gcfbed gdafb bfacegd ebg aged fageb bacfe | ge gefcdba ge bgdfa +adbgec fdceg afdgc bedf cfe fe gaecbdf faebgc gcbed fcbedg | acfdg gdeabc debf ef +dfgbe da ecbadg dafeg fadb gfdbea dagcfbe dbgfec cfgea dga | befdg agd eafdg fabd +bedc aefbc ceadfb fdb cbagfed fecgab dcfba gaebdf cfagd bd | db bfd bfcae adgefb +cabedgf edbfgc gedcfa bacegf fde dgbf baced fd fedbc fegbc | fcdeb adbgefc adecgbf fde +fged egafc ecafgd efcda dfa dfcabg becfag fd agcdfbe ecdab | dgef fd dgfe df +deafgb gbfdc dg dbg agdc dbcafg cadfb bafced fgbce daegbfc | gbfdac afdgcb dgb gdcfb +dfecb fabdge cegbaf fdca faecb aefcdb bdf gdbce afgcebd fd | dbf fbd edcabgf fadc +cbf egabfdc fdcgba fabecd cf dfagb gfac adbegf cdegb bcfgd | acfg afgbed cgdfab fc +ebdfagc bcfa gecfdb af daegbf fgcbd bcdfag egcda fgdca gfa | fcab gafcdb dbfega acfb +adfbg eacb abfcg ecafbg gface ecfgad bc degfbc cbg gabdefc | cb gabefcd cagfebd agcbfe +ebgad bef gacfe gceadf fb efcagbd eabfcd cegfab gbfc ebagf | cefadg fcgae fgbc ebacdgf +dcg aged efacd cfgdae edacbf edfcg bcagdef gd fecbg dcfbag | cdeabgf gd gcd adge +fecgda cdabefg gabfc gfacbd ecgabf cbafe bcdef ea ace bgea | egba gabe beagfdc fbcag +bacdgf eafbd cagde becad afgcedb bc fbegad cfbe cba fcdaeb | fcbe abc dbecaf edcba +ecbdf dagfceb abcfde cbade aebgc adb bfgead debfgc cafd ad | bad dcaf begac da +gbae deafb fdgbea cegfd ag cdaefb cgabefd degfa dag dfcgab | baeg agefdb bcdafg cbdfga +ebcdf gdeafbc cdgbfe eaf cdfa deafbc gedab aecfbg ebadf af | befacd ebfda af af +cfab dcb gfedbac bc cgaedb fbdge cbfdg acgbdf gdcaf acgdfe | bc fcab afcb dbc +edbag gebdc bedfag eacdbg bcedgfa ecab ec gaedcf bdcfg cge | ce ceab ec bdegcaf +fedcba fbgca cbafge ef gbdacf efbgcad gefca befg ecdga afe | fea adgfcb fcage bcdfae +da edfgc cgfdba adfecgb gfaeb dcefga fecdgb gad gdeaf ecad | cedfg dbfcega gfcaed abdcfeg +fcgbed fcbedga cafbe gdceba bcafge bfe fagb fb eacbg facde | cdfbeg fb ebgcadf fgcedba +fecdb fdcbae afdeg cdfea aec efgbadc ca cbfa dcagbe gbefdc | facb fabc fcdbega efadcb +dagcf gadfeb ad dfegbc cgdfba dbac abgecfd dcgfb cfgae adf | fgadc cbda ad cfagd +fdgcb agedbc cdbef feac efb ef febdac afdegb abced edgafcb | fe bfecd dcebf cafe +cafdbg eaf fe gebf befcag cfbga cgaef fdaecbg edcga febacd | gfbe egbf aebgcdf faceg +bfc febg cdfga dafbec cegbd fb cdbgfe cbfgd cadegb gbefdac | dcefgb dbfcg deafbc gbdec +bacgd cedfbg cf aefc dfc aecgdf adfcgeb gafed cafgd baefdg | dgafc fc dfc gfbced +bcge fgc efcdab ecgafb cfeab fabgd fagbc bgcdeaf efcagd cg | cbeg bdagf bcgaf fgc +cdaeg fbaec ceafd fd cfd adfceb bgaecf dbcegf bdaf cgeabdf | df cdf fdagbce cbedaf +dgcbf gecfadb gbdecf gfdbca fbagde ad cdgab dag afcd caegb | cgbedf dfac bdacfeg cafdbg +defacg bd cdbegaf cfaeb dbf cbefgd cgdaf cfbgda facbd gabd | gfadec bdf gbad adgcef +bagdce deagcf bcdf cfa abgfdc cf geacfbd afgeb bacfg dcagb | cf cdbf aedcbfg fbdc +fbceda bedcf dg gefcdb aefbgd gdf cgde gfacb bdcfg dfcegab | dfbagec dfg cabdfeg gd +gda cfgbde dgbfc fgabdc fcagd cagfe baecgdf faebdg ad adbc | efgdcb dag dacb ad +dagec eca fgeacd cdefab gfdacbe afged dabgfe ac dcebg afgc | bdgce ecdga eagdc ca +da bda gadc dbafg fabgc faedcb dfcbgea agcfbe bedgf gfbadc | acbfegd gfabdc bad da +gdce aebfdg faebc fcdabg acgfedb eacgdb adc adgeb cd daceb | cd cgbadf cad edcg +caedb agbed gfbcad eca fdce gbface baefdcg acfdb fbedca ce | eac cebadf fagcdb cae +fcbadeg fcae bfdca ceb ec cdebaf ecbdf gcedab bgdfe dfagcb | geabcd acef agbced gdbeafc +cbdef degba efbad eafc dbcfge ecdafb af fcbgad edfbcag baf | gbdea ecaf eacf egfcdab +fcde gabfd cdgeba fac fc dcabe bfaced dacbf ebgfac cgfbeda | adcfb fca gebdfca fadbc +fdceg cbd edcgfa cb cdgfeb gdebac edgcafb fceb agbdf bgcfd | adfgce beacdgf bc cedfbag +fcbegda dbcefg gcebad gbfc cdb gfbaed bc cebfd ecdfa bdegf | dcb gabedf beafdg bc +cfaed bacdg egd aegcdf gcef gedac cdbefga afdgbe bdfaec eg | gcade cefad bdgfea gaedc +ac dbeacg ace defba fcaebdg dabfce abfedg dcaf cbfae efbcg | fegdba cfbae cea dbacfe +dgcaef bgcaef cfdgeb gd fgecb dcgfbae gebfd bgdc adebf fdg | gdf dafgbec dfg adfeb +ag cadg cgfed aefbc bcegdf agdfbe agf egfca gefcdba gdfeac | dgca dgcaef cdga adebcfg +dfcgbe badg aedgc eabfc dfcbega cgdafe eagbc aegcdb gbe bg | acfdge bge adbg bg +bcfage adcefg dfagc fgaec cdf abcgd dcbgafe df dfae fgcbed | df cfd eacgf fdc +cbadfe bfg cfgebd cbdg edfgbca bg egbdf feagcb fedag cefdb | fgdeb gfb fbdeca bgcd +bcde fdcgba abfcde dbfac abefc befga aec ce acfdge afdegbc | fcbad eac ec becd +ce cbagdf gdcbf cfaebdg gcbe acfdge fcdegb dbaef cef bcefd | acbgdfe cfebd gcebdf ec +ecgbd eacbf cgadeb edf ecafbdg afgebd dcgf ecfbd fgcbed fd | bcfea edf efgabcd df +dgbf egafcd cfedbag cgb abcef dcefg ebcfg cgeadb bg cgbfed | adfgebc egbcf cfeab gaefbdc +gecbfd gbedc dgabcef baefgd abegc dbfce bfdace dg gdb dfcg | dfgc bedfac dg dbg +acbdgf daeb gcbeaf gdfce adefg fbdga cbdfega fae fgdbea ea | ea fcdgaeb ae gecfadb +ga bdgafe bcaed dcgaebf bacfed acedg gbadec edgfc agd bcga | adg dga agcb fdecgab +ebdcfg cfbdg ecgabf gcd edfc fdcbeag ebcdag dabgf dc cgebf | cd gcd gacbde cd +egdfac bf afebdg baf bfdeca bgdf fedga egacb gecbafd gbeaf | bfa fb gfdb fb +gcafb dc gecd fecbgda cfdbg dfebgc cdf fbegd dcfbea fgedab | edfcbg dgbcf cd dcf +badf fcagd agcefb dfgcab ba dcbeg cedabgf abgdc acegfd abg | ebfagc dfab ab fcbdeag +cfgbad gdbfe fe efgdacb cbdge dabgfe egdcaf befa bdgfa egf | decagfb eabf baef fe +dbfea bcaefdg dcfgeb ag bfceag egfcda becfg fgeba gcab ega | agbfecd aedfcgb gcba ga diff --git a/2021/tests/day8.txt b/2021/tests/day8.txt index e69de29..c9f629b 100644 --- a/2021/tests/day8.txt +++ b/2021/tests/day8.txt @@ -0,0 +1,10 @@ +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