Skip to content

Instantly share code, notes, and snippets.

@dbyrne
Created March 17, 2011 16:27
Show Gist options
  • Save dbyrne/874621 to your computer and use it in GitHub Desktop.
Save dbyrne/874621 to your computer and use it in GitHub Desktop.
Project Euler #18 & #67 - Haskell
maxPath (x:y:xs) = maxPath (z:xs)
where z = zipWith (+) (zipWith max x (tail x)) y
maxPath [[x]] = x
convert = map (map read . words)
prob67 = show . maxPath . reverse . convert . lines
main = readFile "triangle.txt" >>= putStrLn . prob67
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment