Reverse words in a string: Difference between revisions

Content added Content deleted
No edit summary
m (added whitespace to the task's preamble, changed the example text to not use quotation marks.)
Line 6: Line 6:


;Example:
;Example:
<tt>Hey you, Bub!</tt> &nbsp; would be shown reversed as: &nbsp; <tt>Bub! you, Hey</tt>
<big><big><code>Hey you, Bub! </code></big></big> &nbsp; would be shown reversed as: &nbsp; <big><big><code> Bub! you, Hey </code></big></big>



Tokens are any non-space characters separated by spaces (formally, white-space); &nbsp; the visible punctuation form part of the word within which it is located and should not be modified.
Tokens are any non-space characters separated by spaces (formally, white-space); &nbsp; the visible punctuation form part of the word within which it is located and should not be modified.
Line 12: Line 13:
You may assume that there are no significant non-visible characters in the input. &nbsp; Multiple or superfluous spaces may be compressed into a single space.
You may assume that there are no significant non-visible characters in the input. &nbsp; Multiple or superfluous spaces may be compressed into a single space.


Some strings have no tokens, so an empty string (or one just containing spaces) would be the result.
Some strings have no tokens, so an empty string &nbsp; (or one just containing spaces) &nbsp; would be the result.


'''Display''' the strings in order (1<sup>st</sup>, 2<sup>nd</sup>, 3<sup>rd</sup>, ···), &nbsp; and one string per line.
'''Display''' the strings in order &nbsp; (1<sup>st</sup>, 2<sup>nd</sup>, 3<sup>rd</sup>, ···), &nbsp; and one string per line.


(You can consider the ten strings as ten lines, and the tokens as words.)
(You can consider the ten strings as ten lines, and the tokens as words.)