projects
/
advent-of-code-17.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
3608c12
)
Day 14 done
author
Neil Smith
<neil.git@njae.me.uk>
Thu, 14 Dec 2017 12:38:10 +0000
(12:38 +0000)
committer
Neil Smith
<neil.git@njae.me.uk>
Thu, 14 Dec 2017 12:38:10 +0000
(12:38 +0000)
src/advent14/advent14.hs
patch
|
blob
|
history
diff --git
a/src/advent14/advent14.hs
b/src/advent14/advent14.hs
index 206d43ec04f0faaca0cce94ce3f1addbe765a99e..45c9dd2c45a67ea85f7714e93b2cb27899b37006 100644
(file)
--- a/
src/advent14/advent14.hs
+++ b/
src/advent14/advent14.hs
@@
-13,6
+13,7
@@
puzzleKey = "xlqgujun"
main :: IO ()
main = do
print $ part1 puzzleKey
main :: IO ()
main = do
print $ part1 puzzleKey
+ print $ part2 puzzleKey
-- part1 :: String -> Int
-- part1 key = sum rowCounts
-- part1 :: String -> Int
-- part1 key = sum rowCounts
@@
-26,7
+27,7
@@
part1 key = sum rowCounts
-- part2 :: String -> Int
-- part2 :: String -> Int
-part2 key = cells
+part2 key =
length $ cellEdges
cells
where binHashes = map binHash $ rowSpecs key
cells = presentCells binHashes
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
-- 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]
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
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