diff --git a/14.hs b/14.hs index f11816e..b690ee4 100644 --- a/14.hs +++ b/14.hs @@ -2,7 +2,8 @@ import Data.List.Split (chunksOf) import Data.Char (ord) import Data.Bits (xor) import Text.Printf (printf) -import Data.Graph (graphFromEdges, scc) +import Data.Graph (scc, graphFromEdges) +import Data.Tuple.Select (sel1, sel2) import Data.Sequence (Seq, index, fromList) type Length = Int @@ -46,8 +47,5 @@ getEdges ind (str, edges) = if str ! ind == '0' then (str, edges) else main :: IO () main = do let hashes = concat $ map (sparseHash . (++ [17, 31, 73, 47, 23]) . map ord . ("ffayrhll-" ++) . show) [0..127] - used = length . filter (== '1') $ hashes - (_, edges) = foldr getEdges (fromList hashes, []) [0..128 * 128 - 1] - (graph, _, _) = graphFromEdges edges - print $ used - print $ length . scc $ graph \ No newline at end of file + print $ length . filter (== '1') $ hashes + print $ length . scc . sel1 . graphFromEdges . sel2 $ foldr getEdges (fromList hashes, []) [0..128 * 128 - 1] \ No newline at end of file