Skip to content

Instantly share code, notes, and snippets.

@iMel408
Created March 27, 2019 00:11
Show Gist options
  • Save iMel408/eee9b89dd7ca3a7a32fe7bb31b3b2a9b to your computer and use it in GitHub Desktop.
Save iMel408/eee9b89dd7ca3a7a32fe7bb31b3b2a9b to your computer and use it in GitHub Desktop.
samp_list = ['m','e','l']
def list_perm(prefix,suffix):
suffix_size = len(suffix)
if suffix_size == 0:
print(prefix)
else:
for i in range(0,suffix_size):
new_pre = prefix + [suffix[i]] # [] + ['m']
new_suff = suffix[:i] + suffix[i+1:] # [] + ['e','l']
list_perm(new_pre, new_suff)
list_perm([],samp_list)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment