Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

3
  • Thanks! Worked great! Btw though you wrote 'w' instead of 'word' in the for loop Commented Jan 27, 2017 at 15:39
  • Note that the two algorithms possibly produce different results. The second collects all permutations that occur in the original list, except for the original word (which is debatable). Whereas the first algorithm (if...elif...elif...) only records the first match - all further permutations are mistakenly skipped. Commented Jan 27, 2017 at 16:34
  • 1
    @user1016274 No, what is being appended to the correctWords in my second code example is the original word, not the permutation perm. And once any permutation match has been found, the remaining permutations of that word are no longer being looked at (that’s what the break does, essentially moving to the next word). Commented Jan 27, 2017 at 17:52