Skip to content

Instantly share code, notes, and snippets.

@ColemanGariety
Last active October 28, 2016 01:20
Show Gist options
  • Save ColemanGariety/1b74561efa8c235a17b7787e028b4245 to your computer and use it in GitHub Desktop.
Save ColemanGariety/1b74561efa8c235a17b7787e028b4245 to your computer and use it in GitHub Desktop.
partitionAll :: Int -> Int -> [a] -> [[a]]
partitionAll _ _ [] = []
partitionAll w s xs = (take w xs) : partitionAll w s (drop s xs)
largestProductInSeries :: Int -> [Int] -> Int
largestProductInSeries l xs = maximum $ map (product) $ partitionAll l 1 xs
main = do
f <- readFile "008.txt"
let s = filter isDigit f
let xs = map (read . (:"")) s :: [Int]
print $ largestProductInSeries 13 xs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment