function + minimised reverse-words-in-string solution