Reverse Letters, Keep the Case Pattern
s is a line of words made of letters, separated by single spaces (or the empty string). Reverse the letters of every word, but keep the pattern of uppercase and lowercase positions: a position that held an uppercase letter holds an uppercase letter afterwards, and a position that held a lowercase letter holds a lowercase letter. The words stay in their order and the spaces stay where they are.
For example "Hello World" becomes "Olleh Dlrow": Hello reversed is olleh, and because only the first position was uppercase the result is Olleh.
Example 1
Each word is reversed and then recased so the first letter stays uppercase and the rest lowercase.
Example 2
The pattern of McDonald is upper, lower, upper, then five lowercase; the reversed letters dlanodcm get that pattern.
Constraints
0 <= len(s) <= 60shas letters of either case and single spaces between words only
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.