30
2
Sona is in her house with her 10 year old daughter. She needs to go to school to bring back another child from school, as school is over at 2 pm. It's hot outside, so she wants to leave her younger child at home.
She gave a bunch of strings to her child to keep her busy while she is gone. She asked her to reverse the words in the string. There are lot of strings, so you need to help her daughter in solving this huge task.
So, given a string that contains words separated by single space, reverse the words in the string. You can assume that no leading or trailing spaces are there.
The string will only contain [a-zA-z ]
, so you don't need to handle punctuation.
You will be given a string as an input, and you should output a string.
Sample Test Cases:
Input:
Man bites dog
Output:
dog bites Man
Input:
The quick brown fox jumps over the lazy dog
Output:
dog lazy the over jumps fox brown quick The
Input:
Hello world
Output:
world Hello
Scoring
This is code-golf. Shortest answer in bytes wins.
1Related. – Martin Ender – 2017-05-17T15:02:29.403
1Can we take the input as a list of words? (i.e.
['man', 'bites', 'dog']
) – Rɪᴋᴇʀ – 2017-05-17T15:18:38.0903Can the output have trailing whitespace? – Digital Trauma – 2017-05-17T16:13:08.480