Haskell
chunks :: String -> [String] chunks (a:b:c:d:e:rest) = [a, b, c, d, e] : chunks (b:c:d:e:rest) chunks _ = [] digit5 :: Int -> Int digit5 number = read $ foldl max "" $ chunks $ show number main :: IO () main = do print $ digit5 1234567890 -- 67890 print $ digit5 1234567898765 -- 98765 print $ digit5 7316717 -- 73167
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Haskell