From 9e7558c3dea09ba021f54d80d4c4c9ab4c300414 Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Mon, 4 Dec 2017 09:51:05 +0100 Subject: Day 4 --- 2017/4.hs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 2017/4.hs (limited to '2017/4.hs') diff --git a/2017/4.hs b/2017/4.hs new file mode 100644 index 0000000..2f541c6 --- /dev/null +++ b/2017/4.hs @@ -0,0 +1,14 @@ +import Control.Monad +import Data.List + +hasDups :: Eq a => [a] -> Bool +hasDups (a:b:cs) | a == b = True + | otherwise = hasDups (b:cs) +hasDups _ = False + +main :: IO () +main = do + input <- liftM (map words . lines) (readFile "4.in") + + print $ sum $ map (fromEnum . not . hasDups . sort) input + print $ sum $ map (fromEnum . not . hasDups . sort . map sort) input -- cgit v1.2.3-54-g00ecf