Guest User

Untitled

a guest
Jun 13th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.27 KB | None | 0 0
  1. def permutations(l, indexlist=[]):
  2. if len(l) == len(indexlist):
  3. print [l[i] for i in indexlist]
  4. else:
  5. for i in xrange(len(l)):
  6. if not i in indexlist:
  7. indexlist.append(i)
  8. permutations(l, indexlist)
  9. del indexlist[-1]
  10.  
  11. permutations([1, 2, 3, 4])
Add Comment
Please, Sign In to add comment