From 46ca9a3347227a19c59106697b7e68ddc4c2ff86 Mon Sep 17 00:00:00 2001 From: Jonathan Chan Date: Mon, 11 Dec 2017 23:05:16 -0800 Subject: [PATCH] Day 12 - minor refactoring --- 12.hs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/12.hs b/12.hs index 3bb9048..388fdfa 100644 --- a/12.hs +++ b/12.hs @@ -1,5 +1,5 @@ import Data.List.Split (splitOn) -import Data.IntMap (IntMap, findWithDefault) +import Data.IntMap (IntMap, findWithDefault, keys) import Data.IntSet (IntSet, member, notMember, insert, delete, empty, size, findMin) import qualified Data.IntMap as M (fromList) import qualified Data.IntSet as S (fromList, null) @@ -25,8 +25,6 @@ countGroups hashmap count hashset = if S.null hashset then count else main :: IO () main = do - keyvals <- fmap (map parseLine . lines) $ readFile "12.txt" - let hashkeys = S.fromList . fst . unzip $ keyvals - hashmap = M.fromList keyvals + hashmap <- fmap (M.fromList . map parseLine . lines) $ readFile "12.txt" print $ size $ visit hashmap 0 empty - print $ countGroups hashmap 0 hashkeys \ No newline at end of file + print $ countGroups hashmap 0 . S.fromList . keys $ hashmap \ No newline at end of file