Task
- The user inputs a sentence - words only. Any input other than letters or spaces, including integers and punctuation, should throw an exception: "Sentence must only use letters".
- The output has a pattern, where some words are reversed and others words are normal.
- The pattern starts as a normal word, the next two words are reversed, then the next two words are normal and the pattern continues.
- An example of where the words should be normal and where words reversed is below:
Normal - Reversed - Reversed - Normal - Normal - Reversed - Reversed - Normal ...
Input Example
She sells Sea shells on the Sea shore
Output Example
She slles aeS shells on eht aeS shore
Additional Rules
- If capital letters are used, they should remain on the letter they were originally posted on.
- Any multiple spaces initially posted on input should be reduced to one space. For example
Programming Puzzles and Code Golf
becomesProgramming selzzuP dna Code Golf
Shortest Code Wins!!
Happy coding...
Any input other than letters or spaces, including integers and punctuation, should throw an exception: "Sentence must only use letters".
It means implementing a secondary task totally unrelated to the challenge of reversing words, cuts out languages that don't have exceptions, and requires hardcoding or compressing a long string that takes up a lot of the byte count. \$\endgroup\$