Last active
January 14, 2017 09:42
-
-
Save anddam/f2c1f1945be039d7eff4a2c59cd5d5b9 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 permutate(string): | |
"Generate permutations of a string" | |
if not string: | |
yield '' | |
for head in string: | |
for tail in permutate([l for l in string if l != head]): | |
yield head + tail | |
print(list(permutate('ABC'))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment