Problem 22

http://projecteuler.net/index.php?section=problems&id=22

--Haskell (Input data from STDIN), 20090101

import Char (ord, isAlpha)
import List (sort)

split :: String -> [String]
split ['"'] = []
split xs    = let (f, t) = span isAlpha $ dropWhile (not . isAlpha) xs
              in f : split t

main = getLine >>= print . sum . zipWith (*) [1..] . map (sum . map (subtract 64 . ord)) . sort . split

Problem 19

http://projecteuler.net/index.php?section=problems&id=19

--Haskell, 20090101

zeller :: Int -> Int -> Int
zeller y m = if (y + y`div`4 - y`div`100 + y`div`400 + (13*m+8)`div`5 + 1) `mod` 7 == 0 then 1 else 0

main = print $ sum $ map (sum . flip map [3..14] . zeller) [1901..2000]

Problem 18

http://projecteuler.net/index.php?section=problems&id=18

--Haskell (Input data from STDIN), 20090101

process :: [Int] -> [Int] -> [Int]
process f t = zipWith max (zipWith (+) f (init t) ++ [last t]) (head t : zipWith (+) f (tail t))

main = getContents >>= print . maximum . foldl1 process . map (map read . words) . lines