Project Euler 解答

Project Euler Problem 067

Project Euler Problem 067

import System.IO.Unsafe input :: String input = unsafePerformIO $ readFile "067triangle.txt" lis :: [[Integer]] lis = map (map read . words) $ lines input ans1 :: [Integer] ans1 = foldr1 f lis f :: (Num t, Ord t) => [t] -> [t] -> [t] f xx acc = imp xx acc where imp [x] (y:z:_) = [x + max y z] imp (x:xs) (y:z:zs) = x + max y z : imp xs (z:zs) -- 7273 main :: IO () main = print ans1

since 2013