diff options
Diffstat (limited to '2017/2.hs')
-rw-r--r-- | 2017/2.hs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/2017/2.hs b/2017/2.hs new file mode 100644 index 0000000..47ff161 --- /dev/null +++ b/2017/2.hs @@ -0,0 +1,13 @@ +import Control.Monad + +main :: IO () +main = do + input <- liftM (map (map read . words) . lines) (readFile "2.in") :: IO [[Int]] + + print $ sum [maximum l - minimum l | l <- input] + + let f = fst . head . + filter ((/=1) . fst) . filter ((==0) . snd) . + concat . concatMap (\(a,b) -> [map (a `divMod`) b, map (`divMod` a) b]) . + (\l -> zip l (repeat l)) + print $ sum $ map f input |