summaryrefslogtreecommitdiff
path: root/2017/1.hs
blob: 884e00ed6dfe36fd87e8a0900d929b4795bea009 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
import Control.Monad
import Data.Char

main :: IO ()
main = do
    input <- liftM (filter isDigit) $ readFile "1.in"

    print $ sum $ map (\(a,b) -> read [a] * fromEnum (a == b)) $
        zip input (tail (cycle input))

    print $ sum $ map (\(a,b) -> read [a] * fromEnum (a == b)) $
        zip input (drop (length input `div` 2) (cycle input))