Solution to an exercise in finding words with special properties