Refactor 'word ladder'.