Created
September 22, 2014 15:28
-
-
Save fulmicoton/39edca01c9293c6cf999 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def find_permutations_range(w): | |
if len(w) == 0: | |
yield "" | |
else: | |
for rank in range(len(w)): | |
w_without_rank = [l for (i, l) in enumerate(w) if i != rank] | |
for perm in find_permutations_range(w_without_rank): | |
yield w[rank] + perm | |
for w in find_permutations_range("jambon"): | |
print w |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment