Skip to content

Instantly share code, notes, and snippets.

@Javran
Created March 19, 2016 17:35
Show Gist options
  • Save Javran/cd6ae01a3657f0b4d5b8 to your computer and use it in GitHub Desktop.
Save Javran/cd6ae01a3657f0b4d5b8 to your computer and use it in GitHub Desktop.
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