summaryrefslogtreecommitdiff
path: root/2017/4.hs
diff options
context:
space:
mode:
authortomsmeding <tom.smeding@gmail.com>2017-12-04 09:51:05 +0100
committertomsmeding <tom.smeding@gmail.com>2017-12-04 09:51:05 +0100
commit9e7558c3dea09ba021f54d80d4c4c9ab4c300414 (patch)
tree56abb71a336d1d74d5c3e5e2de927ffea6ea3186 /2017/4.hs
parent44bb3403d2f42fb8ea48cfdd05b20318d99b0556 (diff)
Day 4
Diffstat (limited to '2017/4.hs')
-rw-r--r--2017/4.hs14
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