Skip to content

Instantly share code, notes, and snippets.

@fulmicoton
Created September 22, 2014 15:28
Show Gist options
  • Save fulmicoton/39edca01c9293c6cf999 to your computer and use it in GitHub Desktop.
Save fulmicoton/39edca01c9293c6cf999 to your computer and use it in GitHub Desktop.
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