Created
January 15, 2020 19:04
-
-
Save imvladikon/078e444987a5831b5ceb7dc3e60b7435 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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