Done day 8, but brittle
authorNeil Smith <neil.git@njae.me.uk>
Wed, 8 Dec 2021 13:41:57 +0000 (13:41 +0000)
committerNeil Smith <neil.git@njae.me.uk>
Wed, 8 Dec 2021 13:41:57 +0000 (13:41 +0000)
advent-of-code21.cabal
advent08/Main.hs [new file with mode: 0644]
data/advent08.txt [new file with mode: 0644]
problems/Screenshot 2021-11-22 at 19.25.23.png [new file with mode: 0644]
problems/day08.html [new file with mode: 0644]

index 11a6fbd18705b9832702c058efab83c1ae2432fa..82dc2ad630bf495c24ba6058ee7806c43d310853 100644 (file)
@@ -114,3 +114,8 @@ executable advent07
   import: common-extensions, build-directives
   main-is: advent07/Main.hs
   build-depends: split
+
+executable advent08
+  import: common-extensions, build-directives
+  main-is: advent08/Main.hs
+  build-depends: text, attoparsec, containers
diff --git a/advent08/Main.hs b/advent08/Main.hs
new file mode 100644 (file)
index 0000000..5e51f28
--- /dev/null
@@ -0,0 +1,138 @@
+-- Writeup at https://work.njae.me.uk/2021/12/04/advent-of-code-2021-day-4/
+
+import Data.Text ()
+import qualified Data.Text.IO as TIO
+
+import Data.Attoparsec.Text
+import Control.Applicative
+
+import Data.List hiding ((\\))
+import qualified Data.Map.Strict as M
+import Data.Map.Strict ((!))
+import qualified Data.Set as S
+import Data.Set ((\\))
+
+data Display = Display [String] [String] -- patterns, output
+  deriving (Eq, Show)
+
+type Assignments = M.Map Segment (S.Set Char)
+type Encoding = M.Map Char Segment
+type DigitSegments = M.Map (S.Set Segment) Char
+
+data Segment = Seg1 | Seg2 | Seg3 | Seg4 | Seg5 | Seg6 | Seg7  
+  deriving (Eq, Ord, Show)
+  
+
+main :: IO ()
+main = 
+  do  text <- TIO.readFile "data/advent08.txt"
+      let displays = successfulParse text
+      print $ part1 displays
+      print $ part2 displays
+      -- let td = successfulParse "acedgfb cdfbe gcdfa fbcad dab cefabd cdfgeb eafb cagedb ab | cdfeb fcadb cdfeb cdbaf"
+      -- print $ part2 td
+
+part1 displays = sum $ map countUniques displays
+
+countUniques (Display _ outputs) = length uniqLens
+  where outLens = map length outputs
+        uniqLens = outLens `intersect` uniqueLengths
+
+uniqueLengths = [2, 3, 4, 7]
+
+segmentNames = S.fromList "abcdefg"
+
+digitSegments :: DigitSegments
+digitSegments = M.fromList
+  [ (S.fromList [Seg1, Seg2, Seg3, Seg5, Seg6, Seg7], '0')
+  , (S.fromList [Seg3, Seg6], '1')
+  , (S.fromList [Seg1, Seg3, Seg4, Seg5, Seg7], '2')
+  , (S.fromList [Seg1, Seg3, Seg4, Seg6, Seg7], '3')
+  , (S.fromList [Seg2, Seg3, Seg4, Seg6], '4')
+  , (S.fromList [Seg1, Seg2, Seg4, Seg6, Seg7], '5')
+  , (S.fromList [Seg1, Seg2, Seg4, Seg5, Seg6, Seg7], '6')
+  , (S.fromList [Seg1, Seg3, Seg6], '7')
+  , (S.fromList [Seg1, Seg2, Seg3, Seg4, Seg5, Seg6, Seg7], '8')
+  , (S.fromList [Seg1, Seg2, Seg3, Seg4, Seg6, Seg7], '9')
+  ]
+
+
+-- combine = M.unionWith intersect
+
+part2 displays = sum $ map decodeOneDisplay displays
+
+decodeOneDisplay display = findCode invAllocation display
+  where allocation = allocate display
+        invAllocation = invertAssignment allocation
+
+allocate :: Display -> Assignments
+allocate (Display examples _) = assignments6
+  where 
+    -- segments 3 and 6 are given by pattern of length 2 (digit 1)
+    dSegs1 = S.fromList $ head $ filter ((== 2) . length) examples
+    assignments0 = M.fromList [(Seg3, dSegs1), (Seg6, dSegs1)]
+    -- segment 1 is the one in pattern of length 3 (digit 7) that's 
+    -- not in segments for digit 1
+    dSegs7 = S.fromList $ head $ filter ((== 3) . length) examples
+    assignments1 = M.insert Seg1 (dSegs7 \\ dSegs1) assignments0
+    -- segments 2 and 4 are the ones in pattern of length 4 (digit 4)
+    -- that aren't in pattern for digit 1
+    dSegs4 = (S.fromList $ head $ filter ((== 4) . length) examples) \\ dSegs1
+    -- segments 1, 4, 7 are the common ones in digits 2, 3, 5
+    dSegs235 = S.fromList $ foldl1' intersect $ filter ((== 5) . length) examples
+    -- segment 4 is the common one with digit 4
+    seg4 = dSegs235 `S.intersection` dSegs4
+    -- segment 2 is the other one from digit 4
+    seg2 = dSegs4 \\ seg4
+    assignments2 = M.union (M.fromList [(Seg2, seg2), (Seg4, seg4)]) assignments1
+    -- we now know segments 1 and 4, so deduce segment 7
+    seg7 = dSegs235 \\ (S.union (assignments2!Seg1) (assignments2!Seg4))
+    assignments3 = M.union (M.singleton Seg7 seg7) assignments2
+    -- of the 5-segment digits, segment 2 only in digit 5
+    seg2c = head $ S.toList seg2
+    dSegs5 = S.fromList $ head $ filter (elem seg2c) $ filter ((== 5) . length) examples
+    -- remove known values of segments 1, 2, 4, 7
+    segs1247 = S.unions $ M.elems $ assignments3 `M.restrictKeys` (S.fromList [Seg1, Seg2, Seg4, Seg7])
+    -- segs1247 = S.unions [assignments3!Seg1, assignments3!Seg2, 
+    --                       assignments3!Seg4, assignments3!Seg7]
+    -- what's left is segment 6
+    seg6 = dSegs5 \\ segs1247
+    assignments4 = M.insert Seg6 seg6 assignments3
+    -- segment 3 can't be the same allocation as segment 6
+    assignments5 = M.insert Seg3 ((assignments4!Seg3) \\ seg6) assignments4
+    -- segment 5 is the only one left
+    seg5 = segmentNames \\ (S.unions $ M.elems assignments5)
+    assignments6 = M.insert Seg5 seg5 assignments5
+
+
+invertAssignment assignment = M.foldrWithKey inv1 M.empty assignment
+  where inv1 seg vals invMap = M.insert (head $ S.elems vals) seg invMap
+
+
+findDigit :: Encoding -> [Char] -> Char
+findDigit segmentAssignments code = digitSegments ! segments
+  where codeSet = S.fromList code
+        segmentMap = M.restrictKeys segmentAssignments codeSet
+        segments = S.fromList $ M.elems segmentMap
+
+findDigits :: Encoding -> [[Char]] -> [Char]
+findDigits segmentAssignments codes = map (findDigit segmentAssignments) codes
+
+findCode :: Encoding -> Display -> Int
+findCode segmentAssignments (Display _ codes) = read $ findDigits segmentAssignments codes
+
+
+
+-- Parse the input file
+
+displaysP = displayP `sepBy` endOfLine
+displayP = Display <$> (patternsP <* " | ") <*> patternsP
+
+patternsP = patternP `sepBy` " "
+patternP = many1 letter
+
+-- successfulParse :: Text -> (Integer, [Maybe Integer])
+successfulParse input = 
+  case parseOnly displaysP input of
+    Left  _err -> [] -- TIO.putStr $ T.pack $ parseErrorPretty err
+    Right displays -> displays
diff --git a/data/advent08.txt b/data/advent08.txt
new file mode 100644 (file)
index 0000000..fc92883
--- /dev/null
@@ -0,0 +1,200 @@
+fdceba bafdgc abeg afbdgec gbeacd abced bgc fcdge bg bedgc | bafdec cgefd gcebd ebcgd
+gbfac fegbda fcedagb bea ea abcdef dgbfe gfabe dgea gbdfec | gdea bgefdc bea efdbg
+eg dagef gbcfeda ageb cegbfd gfe dbefa facdg abfged cedbaf | befda daefb egf gcdfa
+edgacfb gcfd dgb degfab bcega bdagc cgafbd fbacd gd fceabd | fbdac gd gdbcaf dgb
+eaf bedgaf dbafc bfceag fedcbg eafdcgb debfa ae adge gdebf | abcdfeg febdg ae daebf
+afbdc aefg ea edbacfg dbefg eab gcbfde abecgd bgefad bfdae | gfea bfdea gbdef fcdebg
+deagf daegc dcgabe abcgdfe gc cabg fedgbc cdg dcafeb ecabd | ebfcdg gcade cfegdb dcg
+agecd bdegca cfea af abdgef fbcaedg gaf dgcfb fadgce afdcg | fadgcbe ecadg bgefad fag
+degcba cfbge cdgaefb gbecfd ae gafdc gfcaeb beaf cae cefag | feba abdcge becagdf bagefdc
+bfcga ecgdbaf facedg cdfae abecf eb dbae ebf ebcdfg cefabd | bafec ebf afdce egadfc
+cfaegbd adbecg ebgca debafg cdfge fa afg cafb fgaec afbcge | gcbaef cdfeg efgacb gaecb
+efacdg egdbfca bcdagf ceadg dface daf bafec dfeg fd cdgabe | efbca cdgae daebcg geafdc
+beg dgfab geaf gdeab fbcagd efdbcag cbdefg edbgfa ge baced | gdfab ge gcbdfa badfg
+gdab bfdeca bgfeac becagd abegdcf edcgf dcb edbcg bgcae bd | dbegc dfbeac cafgbe db
+cefga dc fedcgb dcf fdabe ecbfda dcfea dabc debgaf bfgadec | gafec aebdcgf agdbfe cfega
+bfdec gbac bda dagfeb becdag cagebfd agecd feacgd ab cdaeb | ab bacde ba decgaf
+dbg ecabg gacefd dbaf agefd gebdcf fdacegb bedga fgbade db | dgb gbcefad dbg bdagef
+fbge gaedb eg dbeacf dgcafe gedabfc cdgab aegfdb dbfae ged | dgcba abegd bdacg begda
+abefg ad gcebd dae dfbgce bdeag dgacfe dcab cgafebd geacbd | agfbe ebcgd dagcbe egbda
+gdcfab cdeafb fg dbeacfg gcafe cbeafg gdcea ebcfa gaf fgbe | acfeb fag dcgae acfbgd
+cegfad fedb fbgadce bacdfg acbeg bad fcdabe debac db cefad | fdgcae cfgdea edfcab cefad
+fbg bgec efbac fbgca gb fbcdea bfdgea bdcagef fgadc cbeagf | fgb fegdba fbaedc aefcdb
+aecfd agcdfe bdegcaf efbad bfeadc eb aegbfc dcbe bef dbagf | bcfead fgbcea eb aefdb
+gedab cfdbg egca dfegab gedcb fdebcag acfebd ce cbe decgab | acdbge bfacde bgade cedabf
+edfg fbgdae bagec feagb fbg abgdcf dbefa bdeafc agfdbec fg | dfeg daebf dcbfga gf
+bcgaefd cfbeg cdefgb fcde adgbec acgbf efb gebdc fe dabfeg | abgcf aegbfdc bedacgf edgabc
+dgfbc bfaegc fad dcea adcfg edagbf da eadfgc cdafegb geafc | da fcgad gdbfc afgbce
+cdea bafdgec gcbeaf bcafd fdbga bcd cd ecfba fcebdg efdbac | dfgebc cbd fcbad cdae
+afcegdb edagf ab gbfce ceab gdfbec fdgcba gbeaf gab cgbaef | ecbgaf bgafecd cbea gacbdf
+efgcab ecb bedf be cbfgaed bcdea cdefab ecgad fdacb gafbdc | adfegbc gcafbe fcbgae adecb
+gfecad gc egcf afcbgd ebadcf cag eagcd acefd bagefdc dgeba | gc acg dcafe begad
+dacgb cbadge dcf cf cdbaf afgc bfeda dgfebc bdafgc feabcdg | cgfa dbagcf fcag fagc
+fgb fcabd fdage bafegc bg dgface afgcedb adbgef dfbga bged | abfdc ebfagc agbdf dcfegba
+afd cdfega cdbgfe bgefad dfegc becfa feadc bcfdega da agcd | deafgc fabce da gbcdef
+fcdgb baefgcd fe dgeabc ceabd fde eafc febcad defbag cbedf | bfedca gdcbf daceb ebgdfa
+cbgf bg decafgb ecadgf dcagf gfabd bgcafd gbd cbadge dfeab | cgfb edbfa dbagf gbd
+bda dfgbec efdga cagb bgead egcbad ba dfceba degcb egabcfd | gfead ba gbac egbdc
+bd dab cbgdea dbge bcdga gdcaf fbdgeca abgce abdfec cbegaf | abd bd gebcadf dafcg
+faegcbd bdagcf cdgbfe cb efbdg gdafbe bdc aegcd becf degbc | bc cb fgdabc bc
+cfbae bcfged cafdeg fa acf febcg fegcdba bagf afcgeb dabec | cfgbe egdafc fbgdec cbfea
+dabfgc gdcfbea cedaf gebda dagfec ecbf beacd bac bc cafedb | begda bc decab defcga
+ecd decgf gebc ec dcgaf cfaebd efdbga afebdcg bfedcg dbfge | dgfecba cgeb bfdecg aedbfg
+efb afbgdce fdceg aebg afcbg gdfbca efcgb be dcbfea fagebc | bgfaedc afbcg efdgc cgfeb
+eb adcfeb eab dacbg gebcfad gaedb cgbe gafde gedcba gcfbda | abgde bgdae daefg cfbagd
+cdfeab cgfead bfgdca bfgcead dfcea bdeaf aedgb bf becf bfd | cefb dafce dcebaf edgcafb
+acfbegd bf gfb cbaeg gaefd fegab cafb agebdc bfgdce bcfega | fdbgec faegd eafgd gbf
+eadfg gdc fegbcd ebdfc debcga bceafdg eadcbf bgfc gecdf gc | dcfbea debcf gdefc gdc
+gdb afbdgce gb gfdce dacefg edbfcg bdaecg fegb bdafc gbcdf | cfdbg dbfgc fcdegb debcga
+bfcdg befcd efgb cgdbea ceb eb fdeca efgcbda dcbfag dcebgf | gfbcd ebagdc dabfgc dfbgc
+acefdb afbgd cda ac adcgfb bdgeafc gcaf gabedf bgdac ecbgd | gfbdac dbgca edacfb dfeagb
+cfadb dfcgea aebdgf ba edfacb eafbdgc baec cdbfg abf cadfe | dgcfabe aceb edgcaf afdgeb
+cgfda ec cgdbea gedcabf dfgcab egcf beadf dfeac ecgadf eca | gfcbad feadc fcead gcafd
+edgfa gfbd bg adfcbge agfbde edcgfa abfec abecgd eabfg agb | fcaeb dgcefa facedg bdgf
+db eabcdfg gefcda cbegdf dcbg bdf gedfb edcfg fdecab beagf | ecfadg cgdb bcdg gcfead
+dbeca cdbafg gcdaeb ec feagcbd fdbea cbe gdce bdgac abefcg | cadbg dacbg cbadg bagcef
+cagbfde gbaec cfbage fa bfcadg efacb ecbadg cbfed bfa afeg | gefa abcef dbfcga fbeca
+cdefg degacf dbfca dfcga cedgbf fdgaceb gaed gca ga gcefab | ecgdbf gedcfa gdcef gcdef
+abcdgf acdge eac ea dabefc aegdfbc edcfg cebdag abgdc agbe | aegdc bcgad dcgfe fedacb
+egbcdfa becaf ecbdaf dcaf edabc cbf fc ebgfa bgdaec bdefgc | ebdcfa ecbfa fcb cbagde
+bacfed ecagf ad gadfe aed bdga fdgbe dfaegb gdbefc dbcafeg | gafec gfdeb fadbcge dcegbf
+fcdgbae bgcadf bged eabdc ed bcadg baefc acgdfe eda cdgbae | fbgcda bgcad faceb eagdcf
+fbcd ecfba aegdc dab bceagfd fbdeac db afecbg decab fagbed | cegda bd cgeda bd
+gcdeab gbedcaf gefc defba ced faedc cbgdfa dgcaef ce cgdfa | abgcfd cfgbad cgeabfd dfcga
+ba gfdbac bdgecaf eafcb gface bfa eagb cgefad dfbec bfegca | ebacf ab gdafbc cgfeab
+feadcbg fbg decbag ebgdfc faebdg dabeg feab fb dacfg fgbad | agfdc gefcadb gdfba gfcdbea
+bcgfead adecfg dcfb dbg agfdc egcab fdgbac bd gdbca gfabed | bagedcf gebca fcadg gbd
+adbfec afgecb edf cbefd fegcda deab cfbgd ed cebaf cefbgad | efbcd fegcda bfdacge fgcbd
+bf gcabdfe adefg fdgab adbgc bcgade efagbc cfdb bfa bcgdaf | abf fba bdgaf fagbdc
+fgeadbc bfcgd dcga cd bfedca abcgdf badgf fcegb daegfb cdf | cfd dc bdgcf gcebf
+bgecdf geab abd begdc defcba agcbd ab becagd dcgaf abfcedg | agfdc bda dab dbacfe
+egca gcf aedgf gc dbfgae gebdfc fecdga adbfegc dcbfa afgcd | gfeda deacgf ecgfda deagbf
+cdfbg dafb gcbde bfc aecfbg fagdc agdcfb bf bgcdeaf cagdfe | ceafbg adgcf gdecb bf
+geabfc ecgfa fgebd dgeabc aedgf facd fcedga ead da fbecgad | degfa cdaf aed bacdeg
+dcg cbde abfgcd fcgeab gaceb dc dacbgef cgaed degfa degbca | dcfabg dacgeb debc dcfbga
+agc fcgdaeb gdba dfabc fgced gecbaf efdcba agdcf gcadbf ga | cdefg fcebag ebdfca fcbega
+feabdgc badef fg acfbdg gfed afbge afg dbeafg begac bfcead | fedcab fabge agbefd fcdbae
+bfcead cfe bdgafe cadefg fbdc bacef cgeab fc dbagcfe fbdea | adgfce cfbd cdfage fgacde
+cedg ebcda ebfcga efdbag dcfba cgeba de badcge eda fbcagde | cgaebf beagfd cbgae efagbd
+cfead acegd cedbgf cdafgeb dcebg dabcgf acg aegb ga eacbgd | dcefa agdce ga abge
+ac bdcgf acbefgd cgdaf fdgbca dbcefg bgecaf cbad cfa gfade | gaecfbd adbc fdcgeb adcb
+dcgebfa fcdbg adcgbe bdfcae dec abcfe ed fcebag ebfdc defa | aecgbd dgcfb gcbaef bdfgc
+becdg ag dbcfge fadegb dga ecgbda dgbaefc cafde gbca gaecd | agdebc bfegdc dcafe debfgca
+debgfc dcbaegf dbg afgcd fecgb acbdeg bfgace gcbdf db bfed | fbed bgd db dfcbge
+dcegba gebac adfcg egd debc debagf agdec ecbfga ed fbecdga | dfbage deg efbadg fagceb
+cf dbfgec bfedac bcf egfc bdceg dbaceg fabcdge gbdfc gdabf | cfgdeba dgbcf cedfab cbf
+gaedbfc bdfae gfe fdgeab dbefg gcdeb fdbeca fg efgacd agbf | feabd fdegb dbafe bfead
+fgbce cgdfa ab gdbfea cafbdge cagfb cdgfbe ebgfac bace bfa | ceba afcdg ecfbagd efbgac
+cedgf gc gedaf faecbd dbfceg dcbg cge efbgca bfcde fcbdgae | eafgd cbgd fagde edafg
+dbgfc dbfce de dbe cbgefd dafbcg cabfe debafg fceadgb edgc | abefc cbfadg bcdfe cdeg
+fabde db fbeac dbf dfega ebcfdag cefdba cdbfge dcab gfbace | dgefbc bfd db dacb
+fgaedb ecd dcbfe edafgc dc bgefc edfcab dcba afedbcg fabde | bgcfe fgaedc cd dfgaeb
+adcfe dbcga eb dbe bceda cafgebd aefgdc bedcaf fagdeb fbec | abgdc bde deb bcadgef
+dacgf gafdeb ag cabfdeg bfdac dbfcge gdeacf geca afg cdgef | fcgbde cegfdb fdecga degfc
+fc cbf gfbadec dabef cbfda acebgf gdcf bfgcda bagdc gdebac | gecabf dcgf fbc cdgf
+cbdafe fdabe gdafcbe bcgade adcf dfegb abd agfbec da febca | acgebf bdfaec adb agecbd
+ebgfd fdgcbea dc gfdecb edgc dgabcf afceb dbc bgdfae cfbed | dcebf afebdg adcfbeg gbefdc
+faecbgd gd gabd cdebg dbecf deg cagfed bcaeg fcgabe abdceg | cedgb gebdc cefgad aegcb
+de gbedf dgcebfa gbfae cbde cbadgf dcfgb fedcbg edg cgafed | fgadce daegfc de eagbf
+gadfbc ec bagcf edfacg begfc ecab gdbef cgedafb ecf bgfeca | fbcga dgecaf fce cbea
+afe abdfgc egfcbda gabcf edcafg gcfeba acefb abeg ae ecbfd | degcfab dfaecg gdafbc ecafdg
+acgdb fbgd decfa fg bcegad gfa debfagc gfcbae cabfgd acfgd | bdcga dfgca dagcb cfabgd
+gefac ecfdb acdfbe adfegb gabefcd gd dbcg gdefc cfdebg egd | gdbcfe decgf efdgc gd
+adgfe gfcdeab fgdbea aefcd dfbgec abgf eag egfbd cdbage ga | fgdcbae dbgfae bgdaef edgaf
+bgfae degb cadbef cbagfe dba db gcabdfe fgbad dbegfa gdacf | adgfb dbgaf fcedab dba
+fb cabdgf becgda bgaf gbdfce dagbc cabdf bdf bfagced edcfa | dbcfga badcf aedcf bagdfc
+bdaegf ebgd gdfeacb gd gafbc agd bafgd ecgadf fdbeac dbfae | degacf egdb ebadf dfbeagc
+dfecg bdceg dcbafg cafgedb begdca gcf afedg gdbfce cbef fc | dcfgbe egdabfc cfg fdega
+dgfcab cdefga fcebdag cb bcd abcg dfagc bgfcde cadbf dbfea | bcd fdcbeg gedcfab gcdabf
+edgcbaf gcaf dcbfeg edfcg adcge dceafb cfdage dbeag ace ca | dcbfge fadceb cdegf befacdg
+gacde bgdac gdcbaf fdagb bdc cfbeagd bc gcbf abcfde fbedag | dabfg eafbcd bgcda aefcbd
+ebdcaf cegbd afdbceg faeb cgdefa bfced ef cbfda cef bagdcf | dfebc cfdbag ebcfd aebf
+becgaf adceb decg cad dcafgbe efdba fdbcga bdcaeg cd gebac | bagce dac gbcfad adfbe
+dcaeb geb dgcfb gbafec ge eadg daecfbg ebdacg deacbf ebcgd | dgcbe beg adbec bfadce
+bcfega gcdba gfcab cebgd bdcgafe agd afcd geafdb ad dcagbf | fdca agfbc fadbeg gefbca
+cbdea ecbfd gecafbd def ef efcg fabgcd agedfb bdfcg egbcdf | ecbad fbgced bcfdg fde
+ebgacfd gbfeac gcbde degac ace gbadce gfdac fgbdce ea abde | fdgeabc bedgca ebdgca bdegc
+ca gaedfbc cfa dgfabc bcdgf fbdgec geadf agcfd cbag bedafc | fdcgb bcefdg gdbcf acf
+fcg bcadf cg cfgbde gfbca ebdfacg geca defabg befga acbgef | gfaecdb gbfca fgc gebfa
+cafegb dc gcd dfacg cefga dfagb cade bcedgaf dfcgae bfecdg | cbedfg ecad cd cgaef
+dfcba ad gbdafce bfgdc fgebac dacebf dab dcae gebfad bacfe | bcdfg caed ad cbgfd
+abfegc dbfea aedfgc fdcag cdbg bc fcb fgcdba cfegabd cfbad | fdcab fegcab bdeaf bc
+bcedf abdec ae daegcf gabe bdcga facbdg daecgfb dae edagcb | dea cbdfe bage ea
+eagdfcb adceb dc fecagb cedgab cbeag daebf dgbc adc acdegf | dbgfcea cbead gbfcea geadcfb
+ebadg cdb afbgced badgef bgacf dbcag daec cbedag cd gfcbde | baecgd acfgb adebgc fbdcega
+ceagf egdac aegdcf bgeadfc edc afbecg cfbdae ed gedf bgacd | cgebaf fegacb efcagb ebafcg
+adfgbce acgef adbgef egcfad cafdb cafgb fgbeca gfb gb bgce | bedcafg eacgf gfdace gbf
+baefgdc deacfb egfb gdace bcaefg bg gba aegbc eabfc cdgfba | caged dfaecb gbef ecgbfad
+ca edgacf abdgf gcefba dace gca ebgfcad bdfegc agcdf dcfeg | adefcg fgcbde afgdb ac
+cdafg gdf agcfe fgaebc df dcabg dcfbge acgdef fead gfeadbc | gdfac gcdab fd fagec
+bedag dbfca gdfe gedfba baecgf fe efa dcgaeb defba efgbadc | dgbea bagde aefdb abedf
+cabegf ecbagfd aebcgd dg cbgad gaecb dcge cadfb bgd ebfagd | cegd abgcde gdb afcbd
+abfcd agdef efc bdafgce ce acge gdfcae efgadb efdgcb edcfa | acbdf cfabd cafde gfdeba
+egca bcg dfbaec gefdb ebdac cfbgad cg egcdba becdg bfgecda | ebgacfd becdg ebfgd edgabc
+bfaegdc gfeda ecg ec bacfg cdae aedgcf efgac egdcbf begfad | gabfc adfge afbcgde fbgca
+gacbf adgfbe gdcbfea bcgfea bdf agcfdb cdegb df fbdgc cadf | cedbg gdcbaf gecbd cgdafb
+fgbac fbgad gefcba dbeaf abcfgd dg fdg bfdagce gadc fcebdg | fbdea dbegcf abfgced acfdbg
+gae cfabg dbceg fabgced ea fcbdag ecfa aecbg bfcgae faegbd | aebgc eafc acgbe bcfadg
+fbcad gcbefa acbfdge ecgd cegabd ec dbage aefbgd ecb cbaed | ecadb agebd bgdaec decg
+begac eg ebcfa fgbdca eag gcabd gdcbefa adebgc cged dagbfe | eg eagcb gfacbed cgeba
+gfcdea dbeac ebc bdfceg gfecbad bega agdec bcadf eadbcg eb | cegad cdaeg ecgad gedac
+efbag egfdba agbd fdage gaebdfc daf gceafb cdegf da afcbde | abfge abdg begafc ad
+ceda gfedac ad aegfd egfcba edfgb agfec agd gafbcd gbcdafe | gfdeb ebdgf fcbgea aedbgcf
+fagb cdeag bgfde af afe dgfaceb feagd cabfde bfdgec adbfeg | fcbegd gfaed fea fea
+efcbdg fdagcb de cefba fdcgb dfcagbe fed cegd gdfeab ebdcf | ed gced cdeg ebfgda
+cbdeg bdgac bca aecbdf bdgfec cafgd acdebg ceabgdf ab gaeb | gaebdc geba cbgade ebag
+gedac afcgdeb begc bgaecd fabdcg cga efdac eagdb cg daefgb | dafgebc eacdg gc cbeg
+gaceb bgefca eg bfeg age aebfgdc ebafc abcgd badcef gafdce | bfcage bfeg fcdbgae gabec
+ebgdcf aedf gcfda gefdca eabcfg dgf fd agcdb ecfag fgbeacd | cgdaf gdcba feagcb fdg
+efbag efg ge fdgab befca dfbaeg gdae afbdgc gedfbc fgdbcae | ebgaf edfcgb fbage fge
+gaefbd bf agfecd efadg agfb dbgef ebdcg acefdb feb aegcbfd | egfda gafde gbfa bfe
+dafebgc bfdecg cdaebg da gcdbe dab bfceda adge bdcga bfgca | dcgbae da cagbfed daeg
+ba gcfad adbfg fabdeg dbfegc dbcgfae acdebg aebf bdgef abg | faeb bdefag cgeabd egcabd
+gafb ga fdcgba ebcad gbfcd deacfg dcbga cfegbd agd agebcfd | gecfbd cfbegd cbafdg cegfbd
+fa fab cfbea gbeac cefdb cebagd cdegabf cgfa dabgef faebcg | abf efcab bgaedf gcaf
+cdafeb bg aedcg gab acbfedg gbfd bfaecg bcfda gabdc gdfbac | bg gcdae bgdcfa fbgd
+afdgc gefbda ebfc dgfec dbfge cbdfeg gadceb ced ce dbfcgae | ce edfcg bcef dcgbef
+egbafc fdag ad dcbfaeg cgfba dfacb baecdg dac gcabdf edbcf | fgabecd bacefg agdf befcd
+dcefgba edaf ebafc gbecaf de cedfgb bdace cbfead agdcb dec | gfaceb ed gcbad begfac
+dcea aefdb eaf badcfg ebfdg beafcg ae befdca ceafgdb bacfd | aef dfbea fdgabc afe
+ag bgac dgfebca gea gdace bceda gedcab bcafed egcdf ebdfga | cabed bdeac dcfeg eadcb
+eacbf ecabgd abcegfd cbage agdcef dbge bgc bg dgfacb dagce | cagbe cebdgfa edacfg bg
+abd db cdbefa dagfeb dceaf fcaedg cbade fcbd egbca abfcdge | decab aebcd cafbed cadbe
+gdefb deg bfgaed ebgaf afed fgbcd fbedgca adecgb ed gabfec | fdbcg faegdb fgbae egcfbda
+decf dbfgce ecdfabg acbfge dbe dfbeg fgabd fcegb bdagce de | cegbf bedgf de fadbg
+abgedf cbag fecgd ebcfg fcb bc cebfad abfcge egabf bcegdfa | egfdc abcdef fegcd cgefadb
+cadf feabc da cbgafe bfcdea adb bdagec bfdae bdcegaf gfbed | bcafe adbegc cbfae defcgba
+bdfe db gcdbfe bfcag edbgcfa abegcd fbcgd dfgec gbd adfgce | dgabecf dcgfe db gcfdb
+acf afbceg dbfae cf ecfba abdecgf cgbea gcef fgabcd dbaegc | cfge afedb aebcg gdbcafe
+dgabce fbcea eafdbcg fdcg cd fgdecb fedgb afdegb dbc dfecb | cd dbc aedfbgc cdegba
+fagdbce abd fgbedc decfb bfdace baedc ebfdag agdec bcaf ba | daecb acfdbe cadeb dba
+dfceb bcfedag gbecdf dgfe ebdcaf fg fcg cafdgb ebgca gfbec | bedcf dcefb bfcaed abdefcg
+gcfba badegc bga afbdcge ag fgebc bfacd dfcegb bafegc faeg | gedcfb cadbf fbacg bcgefd
+cbg aedbcf ecbgfda cg fgcdbe ecfbd bcegda afegb bfcge dcfg | fbdce gc bcefd gcedfb
+dgbcf ebgd fgdbca agdfec bdfec ed efcgbd cdgaebf fde fabce | fedacg cdbgf ed efabdgc
+eafgbcd afcgb gbfcda gecabd efgcd acgfeb gecfa ea gae feab | edbgcaf dbgeac gacbf beafgc
+acgfdeb cegabf beacg bacfd dbcea gacbed gcdbef de edb eagd | de dgcbfe ed daeg
+defa cdbagf bfa agbfced cfbegd efdgba egbaf egfbd bcgea af | fa fbadcg gadfebc cafbdg
+dgebcf degab afed gafbd gabfed df gdf bafgc bdcega daecfgb | cebfadg debga abgfd abgfecd
+gdeca dcegba dcagfe ageb acefbgd egdcbf bgd adcgb bg bcadf | fgedbc gbdcef ebag gfbced
+dc edbgcaf cbadf fdc bfdgac bgadf cbgdef fdageb ebafc adcg | dgbaef dfc bfeac bacfe
+eagcbdf caefdb fceda egfab bdca gbdfec efcdga bc ceb eabcf | bface bc bfdeca faecb
+gadec becgdf aedcb gfcdae edagfbc dg gefca acegfb fgad egd | cdeab fagec gd dcgafe
+abdc cedag cd fabdcge agebcd gdeab feagdb gaefc ced gdbcfe | baged fbceagd ecd edc
+gcadeb gabed gfab bdfec abfged fa ecgafd fad gfedcba dbfae | fbced gbaf aegcdb acdgef
+df bcgfe fdb beacgd gefdcab fead aefdbg fbcgda edabg dgbef | efbdg gdefb eafd baefdgc
+daec bfgde gedabcf bgcad ae dbgaec age afcdbg dgeab cafbeg | eag beagd edfbg degbac
+fgbcad agbcd aecbd febcgd fdagceb gdc gc gfdba cafg gaedbf | geafdcb dgefab ecabd dcaeb
+bfgca febag dgefba egda efcbda eab fdbge ae egfcbd gacdbfe | aedg efgba dcagefb efdacb
+bdagec ecbfa daebc gafcb cgdfea efa fdeb dceafb ef gcfdabe | efcba cabged gfabc fbacde
+fe gfabe dbaceg aegcbdf dfcbea fcabg deagb gfde edagbf efa | aedcfb efa afe fe
+adfceb eb gdeb fegbda bcfagd fbe agbdf fgeac gafeb defbacg | ebafg feb agfbe bgde
+cgdaeb ade agbcefd adfecb febad aecfb efgabc fadgb ed fecd | acbgef facbe cgbafe deabf
+bfc fabdgc agcbe dfeac fdabceg ecabf fb bdfe edfcag bdfeca | fb cadebf gdabfc cfbdga
+cfbdge adegfbc cdgeab fbg gedf baecgf bcfda fg cdbge cdgbf | fdge gbecd egfbca cfadb
+dbcfeag gecda bed eb dfcab abeg agfced dcebfg adgceb abecd | be gabe bed fbdac
+fbagec ecfga fgdac ec cbfe agbef gce aefgbd fcgbdae gdaceb | fbadge cfgda gfbace egcaf
+bdcfge cbaefgd cagbde fecab fdecga gafd dfe fd gdace edafc | efd daecf cdaefg eacbf
+cefgda daefc agecfb fce cgdbefa dfcga dbaef ce badgcf gced | fbdgcea ebafd gdefacb fdcag
+ebagd fb fbgd cefda ebcagf cgfbade afegdb bdagce bef badfe | ebafgd bfdgea ecdfa bfdcega
+gcedb fdcb aebgcd bf fcgabe cfbaedg fdbceg bfegd aedgf gbf | bfg cdgeb fdebg cebdg
\ No newline at end of file
diff --git a/problems/Screenshot 2021-11-22 at 19.25.23.png b/problems/Screenshot 2021-11-22 at 19.25.23.png
new file mode 100644 (file)
index 0000000..9c1393b
Binary files /dev/null and b/problems/Screenshot 2021-11-22 at 19.25.23.png differ
diff --git a/problems/day08.html b/problems/day08.html
new file mode 100644 (file)
index 0000000..79ec970
--- /dev/null
@@ -0,0 +1,224 @@
+<!DOCTYPE html>
+<html lang="en-us">
+<head>
+<meta charset="utf-8"/>
+<title>Day 8 - Advent of Code 2021</title>
+<!--[if lt IE 9]><script src="/static/html5.js"></script><![endif]-->
+<link href='//fonts.googleapis.com/css?family=Source+Code+Pro:300&subset=latin,latin-ext' rel='stylesheet' type='text/css'/>
+<link rel="stylesheet" type="text/css" href="/static/style.css?26"/>
+<link rel="stylesheet alternate" type="text/css" href="/static/highcontrast.css?0" title="High Contrast"/>
+<link rel="shortcut icon" href="/favicon.png"/>
+</head><!--
+
+
+
+
+Oh, hello!  Funny seeing you here.
+
+I appreciate your enthusiasm, but you aren't going to find much down here.
+There certainly aren't clues to any of the puzzles.  The best surprises don't
+even appear in the source until you unlock them for real.
+
+Please be careful with automated requests; I'm not a massive company, and I can
+only take so much traffic.  Please be considerate so that everyone gets to play.
+
+If you're curious about how Advent of Code works, it's running on some custom
+Perl code. Other than a few integrations (auth, analytics, social media), I
+built the whole thing myself, including the design, animations, prose, and all
+of the puzzles.
+
+The puzzles are most of the work; preparing a new calendar and a new set of
+puzzles each year takes all of my free time for 4-5 months. A lot of effort
+went into building this thing - I hope you're enjoying playing it as much as I
+enjoyed making it for you!
+
+If you'd like to hang out, I'm @ericwastl on Twitter.
+
+- Eric Wastl
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+-->
+<body>
+<header><div><h1 class="title-global"><a href="/">Advent of Code</a></h1><nav><ul><li><a href="/2021/about">[About]</a></li><li><a href="/2021/events">[Events]</a></li><li><a href="https://teespring.com/stores/advent-of-code" target="_blank">[Shop]</a></li><li><a href="/2021/settings">[Settings]</a></li><li><a href="/2021/auth/logout">[Log Out]</a></li></ul></nav><div class="user">Neil Smith <a href="/2021/support" class="supporter-badge" title="Advent of Code Supporter">(AoC++)</a> <span class="star-count">16*</span></div></div><div><h1 class="title-event">&nbsp;&nbsp;<span class="title-event-wrap">{:year </span><a href="/2021">2021</a><span class="title-event-wrap">}</span></h1><nav><ul><li><a href="/2021">[Calendar]</a></li><li><a href="/2021/support">[AoC++]</a></li><li><a href="/2021/sponsors">[Sponsors]</a></li><li><a href="/2021/leaderboard">[Leaderboard]</a></li><li><a href="/2021/stats">[Stats]</a></li></ul></nav></div></header>
+
+<div id="sidebar">
+<div id="sponsor"><div class="quiet">Our <a href="/2021/sponsors">sponsors</a> help make Advent of Code possible:</div><div class="sponsor"><a href="https://www.tcgplayer.com/adventofcode/?utm_campaign=aoc&amp;utm_source=adventOfCode&amp;utm_medium=aocPromo" target="_blank" onclick="if(ga)ga('send','event','sponsor','sidebar',this.href);" rel="noopener">TCGplayer.com</a> - - . Hiring .NET &amp; . . JS engineers. . . Help us serve . . our community . . of game stores. . &amp; hobbyists!! . ---- JOIN US ----</div></div>
+</div><!--/sidebar-->
+
+<main>
+<script>window.addEventListener('click', function(e,s,r){if(e.target.nodeName==='CODE'&&e.detail===3){s=window.getSelection();s.removeAllRanges();r=document.createRange();r.selectNodeContents(e.target);s.addRange(r);}});</script>
+<article class="day-desc"><h2>--- Day 8: Seven Segment Search ---</h2><p>You barely reach the safety of the cave when the whale smashes into the cave mouth, collapsing it. Sensors indicate another exit to this cave at a much greater depth, so you have no choice but to press on.</p>
+<p>As your submarine slowly makes its way through the cave system, you notice that the four-digit <a href="https://en.wikipedia.org/wiki/Seven-segment_display" target="_blank">seven-segment displays</a> in your submarine are malfunctioning; <span title="Yes, just the four-digit seven-segment ones. Whole batch must have been faulty.">they must have been damaged</span> during the escape. You'll be in a lot of trouble without them, so you'd better figure out what's wrong.</p>
+<p>Each digit of a seven-segment display is rendered by turning on or off any of seven segments named <code>a</code> through <code>g</code>:</p>
+<pre><code>  0:      1:      2:      3:      4:
+ <em>aaaa</em>    ....    <em>aaaa    aaaa</em>    ....
+<em>b    c</em>  .    <em>c</em>  .    <em>c</em>  .    <em>c  b    c</em>
+<em>b    c</em>  .    <em>c</em>  .    <em>c</em>  .    <em>c  b    c</em>
+ ....    ....    <em>dddd    dddd    dddd</em>
+<em>e    f</em>  .    <em>f  e</em>    .  .    <em>f</em>  .    <em>f</em>
+<em>e    f</em>  .    <em>f  e</em>    .  .    <em>f</em>  .    <em>f</em>
+ <em>gggg</em>    ....    <em>gggg    gggg</em>    ....
+
+  5:      6:      7:      8:      9:
+ <em>aaaa    aaaa    aaaa    aaaa    aaaa</em>
+<em>b</em>    .  <em>b</em>    .  .    <em>c  b    c  b    c</em>
+<em>b</em>    .  <em>b</em>    .  .    <em>c  b    c  b    c</em>
+ <em>dddd    dddd</em>    ....    <em>dddd    dddd</em>
+.    <em>f  e    f</em>  .    <em>f  e    f</em>  .    <em>f</em>
+.    <em>f  e    f</em>  .    <em>f  e    f</em>  .    <em>f</em>
+ <em>gggg    gggg</em>    ....    <em>gggg    gggg</em>
+</code></pre>
+<p>So, to render a <code>1</code>, only segments <code>c</code> and <code>f</code> would be turned on; the rest would be off. To render a <code>7</code>, only segments <code>a</code>, <code>c</code>, and <code>f</code> would be turned on.</p>
+<p>The problem is that the signals which control the segments have been mixed up on each display. The submarine is still trying to display numbers by producing output on signal wires <code>a</code> through <code>g</code>, but those wires are connected to segments <em>randomly</em>. Worse, the wire/segment connections are mixed up separately for each four-digit display! (All of the digits <em>within</em> a display use the same connections, though.)</p>
+<p>So, you might know that only signal wires <code>b</code> and <code>g</code> are turned on, but that doesn't mean <em>segments</em> <code>b</code> and <code>g</code> are turned on: the only digit that uses two segments is <code>1</code>, so it must mean segments <code>c</code> and <code>f</code> are meant to be on. With just that information, you still can't tell which wire (<code>b</code>/<code>g</code>) goes to which segment (<code>c</code>/<code>f</code>). For that, you'll need to collect more information.</p>
+<p>For each display, you watch the changing signals for a while, make a note of <em>all ten unique signal patterns</em> you see, and then write down a single <em>four digit output value</em> (your puzzle input). Using the signal patterns, you should be able to work out which pattern corresponds to which digit.</p>
+<p>For example, here is what you might see in a single entry in your notes:</p>
+<pre><code>acedgfb cdfbe gcdfa fbcad dab cefabd cdfgeb eafb cagedb ab |
+cdfeb fcadb cdfeb cdbaf</code></pre>
+<p>(The entry is wrapped here to two lines so it fits; in your notes, it will all be on a single line.)</p>
+<p>Each entry consists of ten <em>unique signal patterns</em>, a <code>|</code> delimiter, and finally the <em>four digit output value</em>. Within an entry, the same wire/segment connections are used (but you don't know what the connections actually are). The unique signal patterns correspond to the ten different ways the submarine tries to render a digit using the current wire/segment connections. Because <code>7</code> is the only digit that uses three segments, <code>dab</code> in the above example means that to render a <code>7</code>, signal lines <code>d</code>, <code>a</code>, and <code>b</code> are on. Because <code>4</code> is the only digit that uses four segments, <code>eafb</code> means that to render a <code>4</code>, signal lines <code>e</code>, <code>a</code>, <code>f</code>, and <code>b</code> are on.</p>
+<p>Using this information, you should be able to work out which combination of signal wires corresponds to each of the ten digits. Then, you can decode the four digit output value. Unfortunately, in the above example, all of the digits in the output value (<code>cdfeb fcadb cdfeb cdbaf</code>) use five segments and are more difficult to deduce.</p>
+<p>For now, <em>focus on the easy digits</em>. Consider this larger example:</p>
+<pre><code>be cfbegad cbdgef fgaecd cgeb fdcge agebfd fecdb fabcd edb |
+<em>fdgacbe</em> cefdb cefbgd <em>gcbe</em>
+edbfga begcd cbg gc gcadebf fbgde acbgfd abcde gfcbed gfec |
+fcgedb <em>cgb</em> <em>dgebacf</em> <em>gc</em>
+fgaebd cg bdaec gdafb agbcfd gdcbef bgcad gfac gcb cdgabef |
+<em>cg</em> <em>cg</em> fdcagb <em>cbg</em>
+fbegcd cbd adcefb dageb afcb bc aefdc ecdab fgdeca fcdbega |
+efabcd cedba gadfec <em>cb</em>
+aecbfdg fbg gf bafeg dbefa fcge gcbea fcaegb dgceab fcbdga |
+<em>gecf</em> <em>egdcabf</em> <em>bgf</em> bfgea
+fgeab ca afcebg bdacfeg cfaedg gcfdb baec bfadeg bafgc acf |
+<em>gebdcfa</em> <em>ecba</em> <em>ca</em> <em>fadegcb</em>
+dbcfg fgd bdegcaf fgec aegbdf ecdfab fbedc dacgb gdcebf gf |
+<em>cefg</em> dcbef <em>fcge</em> <em>gbcadfe</em>
+bdfegc cbegaf gecbf dfcage bdacg ed bedf ced adcbefg gebcd |
+<em>ed</em> bcgafe cdgba cbgef
+egadfb cdbfeg cegd fecab cgb gbdefca cg fgcdab egfdb bfceg |
+<em>gbdfcae</em> <em>bgc</em> <em>cg</em> <em>cgb</em>
+gcafb gcf dcaebfg ecagb gf abcdeg gaef cafbge fdbac fegbdc |
+<em>fgae</em> cfgab <em>fg</em> bagce
+</code></pre>
+<p>Because the digits <code>1</code>, <code>4</code>, <code>7</code>, and <code>8</code> each use a unique number of segments, you should be able to tell which combinations of signals correspond to those digits. Counting <em>only digits in the output values</em> (the part after <code>|</code> on each line), in the above example, there are <code><em>26</em></code> instances of digits that use a unique number of segments (highlighted above).</p>
+<p><em>In the output values, how many times do digits <code>1</code>, <code>4</code>, <code>7</code>, or <code>8</code> appear?</em></p>
+</article>
+<p>Your puzzle answer was <code>255</code>.</p><article class="day-desc"><h2 id="part2">--- Part Two ---</h2><p>Through a little deduction, you should now be able to determine the remaining digits. Consider again the first example above:</p>
+<pre><code>acedgfb cdfbe gcdfa fbcad dab cefabd cdfgeb eafb cagedb ab |
+cdfeb fcadb cdfeb cdbaf</code></pre>
+<p>After some careful analysis, the mapping between signal wires and segments only make sense in the following configuration:</p>
+<pre><code> dddd
+e    a
+e    a
+ ffff
+g    b
+g    b
+ cccc
+</code></pre>
+<p>So, the unique signal patterns would correspond to the following digits:</p>
+<ul>
+<li><code>acedgfb</code>: <code>8</code></li>
+<li><code>cdfbe</code>: <code>5</code></li>
+<li><code>gcdfa</code>: <code>2</code></li>
+<li><code>fbcad</code>: <code>3</code></li>
+<li><code>dab</code>: <code>7</code></li>
+<li><code>cefabd</code>: <code>9</code></li>
+<li><code>cdfgeb</code>: <code>6</code></li>
+<li><code>eafb</code>: <code>4</code></li>
+<li><code>cagedb</code>: <code>0</code></li>
+<li><code>ab</code>: <code>1</code></li>
+</ul>
+<p>Then, the four digits of the output value can be decoded:</p>
+<ul>
+<li><code>cdfeb</code>: <code><em>5</em></code></li>
+<li><code>fcadb</code>: <code><em>3</em></code></li>
+<li><code>cdfeb</code>: <code><em>5</em></code></li>
+<li><code>cdbaf</code>: <code><em>3</em></code></li>
+</ul>
+<p>Therefore, the output value for this entry is <code><em>5353</em></code>.</p>
+<p>Following this same process for each entry in the second, larger example above, the output value of each entry can be determined:</p>
+<ul>
+<li><code>fdgacbe cefdb cefbgd gcbe</code>: <code>8394</code></li>
+<li><code>fcgedb cgb dgebacf gc</code>: <code>9781</code></li>
+<li><code>cg cg fdcagb cbg</code>: <code>1197</code></li>
+<li><code>efabcd cedba gadfec cb</code>: <code>9361</code></li>
+<li><code>gecf egdcabf bgf bfgea</code>: <code>4873</code></li>
+<li><code>gebdcfa ecba ca fadegcb</code>: <code>8418</code></li>
+<li><code>cefg dcbef fcge gbcadfe</code>: <code>4548</code></li>
+<li><code>ed bcgafe cdgba cbgef</code>: <code>1625</code></li>
+<li><code>gbdfcae bgc cg cgb</code>: <code>8717</code></li>
+<li><code>fgae cfgab fg bagce</code>: <code>4315</code></li>
+</ul>
+<p>Adding all of the output values in this larger example produces <code><em>61229</em></code>.</p>
+<p>For each entry, determine all of the wire/segment connections and decode the four-digit output values. <em>What do you get if you add up all of the output values?</em></p>
+</article>
+<p>Your puzzle answer was <code>982158</code>.</p><p class="day-success">Both parts of this puzzle are complete! They provide two gold stars: **</p>
+<p>At this point, you should <a href="/2021">return to your Advent calendar</a> and try another puzzle.</p>
+<p>If you still want to see it, you can <a href="8/input" target="_blank">get your puzzle input</a>.</p>
+<p>You can also <span class="share">[Share<span class="share-content">on
+  <a href="https://twitter.com/intent/tweet?text=I%27ve+completed+%22Seven+Segment+Search%22+%2D+Day+8+%2D+Advent+of+Code+2021&amp;url=https%3A%2F%2Fadventofcode%2Ecom%2F2021%2Fday%2F8&amp;related=ericwastl&amp;hashtags=AdventOfCode" target="_blank">Twitter</a>
+  <a href="javascript:void(0);" onclick="var mastodon_instance=prompt('Mastodon Instance / Server Name?'); if(typeof mastodon_instance==='string' && mastodon_instance.length){this.href='https://'+mastodon_instance+'/share?text=I%27ve+completed+%22Seven+Segment+Search%22+%2D+Day+8+%2D+Advent+of+Code+2021+%23AdventOfCode+https%3A%2F%2Fadventofcode%2Ecom%2F2021%2Fday%2F8'}else{return false;}" target="_blank">Mastodon</a
+></span>]</span> this puzzle.</p>
+</main>
+
+<!-- ga -->
+<script>
+(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
+(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
+m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
+})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
+ga('create', 'UA-69522494-1', 'auto');
+ga('set', 'anonymizeIp', true);
+ga('send', 'pageview');
+</script>
+<!-- /ga -->
+</body>
+</html>
\ No newline at end of file