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