main.hs 431 B

12345678910111213
  1. import Data.Char (digitToInt)
  2. import Data.Maybe (catMaybes)
  3. findMax13 numbers =
  4. foldl1 max $ map (\i -> subArrayProduct i 13) [0..((length numbers) - 13)]
  5. where
  6. subArrayProduct start length =
  7. product $ take length (drop start numbers)
  8. main = do
  9. contents <- readFile "input"
  10. let max13 = findMax13 $ map digitToInt $ filter (\c -> c >= '0' && c <= '9') contents in
  11. putStrLn $ show max13