main = getContents >>= print . rhombic_path . map (map read . splitOn ',') . lines

splitOn c xs
 | null xs = []
 | head xs == c = splitOn c (tail xs)
 | otherwise = (takeWhile (/= c)) xs : splitOn c (dropWhile (/= c) xs)

rhombic_path = maximum . rhombic_path []
 where
  rhombic_path acc [] = acc
  rhombic_path acc (ns:nss) 
   | null acc = rhombic_path ns nss
   | length ns > length acc = rhombic_path acc' nss
   | otherwise = rhombic_path acc'' nss
   where
    acc' = zipWith max (zipWith (+) acc ns ++ [0]) ([0] ++ zipWith (+) acc (tail ns))
    acc'' = zipWith (+) ns (zipWith max acc (tail acc))