summaryrefslogtreecommitdiff
path: root/2017/4.hs
blob: 2f541c60f4fbce7a1a61606bbc84bc916e5f8809 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
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