diff options
Diffstat (limited to '2017/4.hs')
-rw-r--r-- | 2017/4.hs | 14 |
1 files changed, 14 insertions, 0 deletions
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 |