Created
December 16, 2013 05:48
-
-
Save prat0318/7982859 to your computer and use it in GitHub Desktop.
Find all permutations
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 print_permutations(str): | |
if(len(str) == 1): return [str] | |
perms = print_permutations(str[1:]) | |
return [x[0:i]+str[0]+x[i:] for x in perms for i in range(len(x)+1)] | |
print print_permutations("abc") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment