aboutsummaryrefslogtreecommitdiff
path: root/0008/main.hs
blob: c852fa7614f82aa191b832b14808d62d8502ee5d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
import Data.Char (digitToInt)
import Data.Maybe (catMaybes)

findMax13 numbers =
    foldl1 max $ map (\i -> subArrayProduct i 13) [0..((length numbers) - 13)]
    where
        subArrayProduct start length =
            product $ take length (drop start numbers)

main = do
    contents <- readFile "input"
    let max13 = findMax13 $ map digitToInt $ filter (\c -> c >= '0' && c <= '9') contents in
        putStrLn $ show max13