Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # every_combo_demo.py
- def permute(seq):
- l = len(seq)
- if l == 1: return [seq]
- else:
- res=[]
- for i in range(len(seq)):
- rest = seq[:i] + seq[i+1:]
- for x in permute(rest):
- res.append(seq[i:i+1] + x)
- res.sort()
- return res
- seq = list("1234")
- thelist = permute(seq)
- thelist = [ ''.join(x) for x in thelist ]
- print thelist
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement