Anagrams refactor and combinations rewrite using for