Skip to content

Instantly share code, notes, and snippets.

@drem-darios
Last active December 29, 2016 05:45
Show Gist options
  • Save drem-darios/293fa9cf2e4ce5ea02cd2c97d12e3116 to your computer and use it in GitHub Desktop.
Save drem-darios/293fa9cf2e4ce5ea02cd2c97d12e3116 to your computer and use it in GitHub Desktop.
Example of how to print all permutations of a String
def permutation(str):
_permutation('', str)
def _permutation(prefix, str):
n = len(str)
if n == 0:
print prefix
else:
for i in range(0, n):
_permutation(prefix + str[i], str[0:i] + str[i + 1:n])
def main():
permutation('abc')
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment