daily pastebin goal
17%
SHARE
TWEET

Untitled

a guest Jun 13th, 2018 49 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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])
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top