fork(1) download
  1. import Data.List (intercalate)
  2.  
  3. main = getLine >>= \s -> let b = length s
  4. c = foldr f [] s
  5. d = show $ read s + b + sum (map read c)
  6. in putStrLn $ s ++ "+" ++ show b ++ "+(" ++ intercalate "+" c ++ ")=" ++ d
  7. where f '-' (x:xs) = ('-':x):xs
  8. f b a = [b]:a
Success #stdin #stdout 0s 4720KB
stdin
-123
stdout
-123+4+(-1+2+3)=-115