Created
March 19, 2016 17:35
-
-
Save Javran/cd6ae01a3657f0b4d5b8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module PyramidSlideDown where | |
-- import Data.Foldable as F | |
import Control.Arrow | |
longestSlideDown :: [[Int]] -> Int | |
longestSlideDown = foldl1 combine >>> maximum | |
where | |
xs `combine` ys = head ls : zipWith max (tail ls) (init rs) ++ [last rs] | |
where | |
ls = zipWith (+) xs (init ys) | |
rs = zipWith (+) xs (tail ys) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment