Skip to main content
4 of 6
added 171 characters in body
user avatar
user avatar

Reverse sentences

The goal of this challenge is to receive an input and output that input but with sentence order reversed. Example Input:

Hello friend. What are you doing? I bet it is something I want to do too!

Example Output:

I bet it is something I want to do too! What are you doing? Hello friend.

As you can tell from the examples, your program has to deal with question marks, exclamation points, and periods. You can assume each sentence has a punctuation and than a space before the next sentence. Trailing spaces/newlines are ok, as long as it is readable. Shortest code wins.

Good luck!

EDIT: You can assume the sentences has no quotes or parentheses, but if you make your code be able to deal with both of those then you get -5 bytes Example output for parens/quotes:

"Hello", she said. (I didn't know what she was talking about). --> (I didn't know what she was talking about). "Hello", she said.
user40734