Name: Anonymous 2009-10-22 19:51
maximumPath :: [[Int]] -> Int
maximumPath tl = head $ foldl (flip reduce) (head rtl) (tail rtl)
where rtl = reverse tl
reduce [] b = []
reduce a [] = []
reduce (a:as) (b:c:bs) = (a + max b c) : reduce as (c:bs)
reduce (a:as) [b] = [a + b]To solve 67 (which is the more interesting one),
trif <- readFile "triangle.txt"
let answer = maximumPath $ map (\l -> map read l) (map words (lines trif))