Skip to content

Instantly share code, notes, and snippets.

@domgreen
Last active August 29, 2015 14:08
Show Gist options
  • Save domgreen/0d623d83f92bff58b4ee to your computer and use it in GitHub Desktop.
Save domgreen/0d623d83f92bff58b4ee to your computer and use it in GitHub Desktop.
Problem8
digs :: Integral x => x -> [x]
digs 0 = []
digs x = x `mod` 10 : digs (x `div` 10)
problem8 :: (Integral a) => a -> a
problem8 a = problem8' (digs a)
problem8' :: (Integral a) => [a] -> a
problem8' xs
| inputLength < 13 = 0
| otherwise = max (product input) (problem8' (tail xs))
where input = take 13 xs
inputLength = length input
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment