Skip to content

Instantly share code, notes, and snippets.

@tioover
Last active December 23, 2015 12:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tioover/6638449 to your computer and use it in GitHub Desktop.
Save tioover/6638449 to your computer and use it in GitHub Desktop.
def P(list, prev=None):
if prev is None:
prev = []
if not list:
print(prev)
return
for i in list:
nprev = prev[:]
nprev.append(i)
nlist = list[:]
nlist.remove(i)
P(nlist, nprev)
P([1, 2, 3, 4, 5])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment