ReverseWords in CodeEval cannot be solved.
https://www.codeeval.com/open_challenges/8/
I'd like to reverse the list in the solution.
Repeat the string for the elements in the list.
How do you think you can solve this problem?
import System.Environment(getArgs)
solve:: [String] - > [String]
solves = fmap reverse ss
main=do
contents<-getContents
mapM_putStrLn$solve$lines contents
In this case, you should first consider creating a list like ["Hello", "World"]
separated by white space and then reversing it.
In words
>words "This is a pen"
>["This", "is", "a", "pen" ]
In unwords
>unwords ["pen", "a", "is", "This" ]
>"pen a is This"
You can do the same translation as .
The correct solve
is listed below (mouse over).
solve::[String]->[String]
solve=fmap(unwords.reverse.words)
© 2024 OneMinuteCode. All rights reserved.