Skip to content

Instantly share code, notes, and snippets.

@PttCodingMan
Created May 12, 2022 10:25
Show Gist options
  • Save PttCodingMan/e1dcbdd511d2ed5ca1ac2633b840bc61 to your computer and use it in GitHub Desktop.
Save PttCodingMan/e1dcbdd511d2ed5ca1ac2633b840bc61 to your computer and use it in GitHub Desktop.
def permutations(data, start_index, end_index):
if start_index == end_index:
print(data)
return
for i in range(start_index, end_index):
data[i], data[start_index] = data[start_index], data[i]
permutations(data, start_index + 1, end_index)
data[i], data[start_index] = data[start_index], data[i]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment