Your challenge is to build a program that puts parentheses around the 'title' part of names. For example,
Sonic the Hedgehog is converted to
Sonic (the Hedgehog).
- Around every
thethat passes the following rules, an opening parentheses will be added before the
theand a corresponding closing parentheses will be added at the end of the string.
- Inputs will only contain words (uppercase/lowercase letters and spaces).
thes are ignored.
- With more than one
thes in a row, every other
theis parenthesized. (So
pig the the the hog hog hogturns into
pig (the the (the hog hog hog)).)
thes are skipped unless surrounded by spaces. For example, the
theirwould not be parenthesized.
I know this may seem lacking in detail. However, it's hard to get one set of really specific guidelines working- just follow the above rules and you're good.
Inspired by this xkcd comic: https://xkcd.com/2252/
code-golf, so least number of bytes wins.