Skip to content

Instantly share code, notes, and snippets.

@ajfg93
Created March 22, 2018 01:04
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 ajfg93/8accdcb540d0e1006f4b789a894f45d7 to your computer and use it in GitHub Desktop.
Save ajfg93/8accdcb540d0e1006f4b789a894f45d7 to your computer and use it in GitHub Desktop.
def qpl(sz, index):
if len(sz) == index:
print(sz)
return
else:
for x in range(index, len(sz)):
if x == 0:
new_array = sz[:]
qpl(new_array, index + 1)
else:
temp = sz[0]
sz[0] = sz[x]
sz[x] = temp
new_array = sz[:]
qpl(new_array, index + 1)
def main():
a = [1, 2, 3, 4]
qpl(a, 0)
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment