From: Neil Smith Date: Thu, 14 Dec 2017 12:38:10 +0000 (+0000) Subject: Day 14 done X-Git-Url: https://git.njae.me.uk/?a=commitdiff_plain;h=a8bef43eb05fec6556efe2addf917d59600b4d65;p=advent-of-code-17.git Day 14 done --- diff --git a/src/advent14/advent14.hs b/src/advent14/advent14.hs index 206d43e..45c9dd2 100644 --- a/src/advent14/advent14.hs +++ b/src/advent14/advent14.hs @@ -13,6 +13,7 @@ puzzleKey = "xlqgujun" main :: IO () main = do print $ part1 puzzleKey + print $ part2 puzzleKey -- part1 :: String -> Int -- part1 key = sum rowCounts @@ -26,7 +27,7 @@ part1 key = sum rowCounts -- part2 :: String -> Int -part2 key = cells +part2 key = length $ cellEdges cells where binHashes = map binHash $ rowSpecs key cells = presentCells binHashes @@ -46,8 +47,8 @@ adjacentCells cells (r, c) = filter (\k -> M.member k cells) possibles -- isPresent rc = length $ rc `member` cells -cellEdges :: CellMap -> Int -cellEdges cells = length $ G.stronglyConnComp [(k, numKey k, map numKey $ adjacentCells cells k) | k <- M.keys cells] +-- cellEdges :: CellMap -> Int +cellEdges cells = G.stronglyConnComp [(k, numKey k, map numKey $ adjacentCells cells k) | k <- M.keys cells] rowSpecs :: String -> [String] rowSpecs key = map (((key ++ "-") ++) . show) [0..127] @@ -96,4 +97,4 @@ densify :: [Int] -> [Int] densify ns = codes where chunks = chunksOf 16 ns compress = foldl1 xor - codes = map compress chunks \ No newline at end of file + codes = map compress chunks