withoutX: remove an x at either end
Given a string, if the first or last character is 'x', return the string without those x's; otherwise return it unchanged. Step through withoutX: the front x is removed first, and then the new string's last character is checked — that's why each check also makes sure the string isn't empty.