import Data.List
main = do
line <- getLine
let raw = words line
let compressed = map count (group raw) :: [(Int, Int)]
let serialized = concat $ map ((a,b) -> [show a, show b]) compressed
putStrLn $ show $ unwords serialized
where count xs = (length xs, read $ xs !! 0)
main = do
line <- getLine
let raw = words line
let compressed = map count (group raw) :: [(Int, Int)]
let serialized = concat $ map ((a,b) -> [show a, show b]) compressed
putStrLn $ show $ unwords serialized
where count xs = (length xs, read $ xs !! 0)
$ ./test
255 255 255 254 254 253 253 253 250 250 250 250 250 0
"3 255 2 254 3 253 5 250 1 0"
$255 255 255 254 254 253 253 253 250 250 250 250 250 0
"3 255 2 254 3 253 5 250 1 0"
문자열과 정수를 오가는게 쉽지 않네여
let 떡칠하는거도 안좋은 습관인거 같은데
분명 한줄로 구현한 버전이 있을듯
http://gall.dcinside.com/board/view/?id=programming&no=410057