在标准输出中禁止引号(hackerrank)

问题描述 投票:-1回答:1

[我正在Haskell的Hackerrank中从事string compression problem工作,并一直停留在IO上。我正在尝试明确删除引号。

compress :: [Char] -> [Char]
compress = ...

main :: IO ()
main = do
    input <- getLine
    let result = compress input
    print $ filter (/='"') result 

代码编译并返回正确的响应,尽管用引号引起来。

Compiler Message
Wrong Answer

Input (stdin)
abcaaabbb

Your Output (stdout)
"abca3b3"

Expected Output
abca3b3
haskell io stdout double-quotes
1个回答
7
投票

您写:

putStrLn result

代替最后一行:

 print $ filter (/='"') result
© www.soinside.com 2019 - 2024. All rights reserved.