Skip to content

Instantly share code, notes, and snippets.

@imvladikon
Created January 15, 2020 19:04
Show Gist options
  • Save imvladikon/078e444987a5831b5ceb7dc3e60b7435 to your computer and use it in GitHub Desktop.
Save imvladikon/078e444987a5831b5ceb7dc3e60b7435 to your computer and use it in GitHub Desktop.
data1 = ["1", "2", "3", "4", "5"]
def permute(data):
if len(data) <= 1:
return data
result = []
for i in range(len(data)):
item = data[i]
tail = data[:i] + data[i + 1:]
for j in permute(tail):
result.append([item, *j])
return result
print(permute(data1))
acc = 0
def sum(n, acc):
if n ==0: return acc
return sum(n-1, acc+n)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment