Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def permutation(s):
- if len(s) == 1:
- return [s]
- perm_list = [] # resulting list
- for a in s:
- remaining_elements = [x for x in s if x != a]
- z = permutation(remaining_elements) # permutations of sublist
- for t in z:
- perm_list.append([a] + t)
- return perm_list
- print(permutation("123456789"))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement