Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # permutate.py
- def perm(z):
- if type(z) == type(''):
- z=list(z)
- sz = len(z)
- if sz <= 1:
- return [z]
- return [p[:i]+[z[0]]+p[i:] for i in range(sz) for p in perm(z[1:])]
- print perm('abcd')
- print
- print perm([1,2,3,4])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement