22 lines
482 B
Python
22 lines
482 B
Python
import time
|
|
|
|
|
|
def permute(picked: str, remaining: str):
|
|
if remaining == "" :
|
|
print(picked + remaining + ", ", end="")
|
|
|
|
else:
|
|
for i in range(len(remaining)):
|
|
pick = remaining[i]
|
|
front = remaining[:i]
|
|
back = remaining[i+1:]
|
|
permute(picked + pick, front + back)
|
|
|
|
def main():
|
|
start = time.time()
|
|
permute("","abcdefghijk")
|
|
end = time.time()
|
|
print(end - start)
|
|
#"abcdefghijk" takes 85 sec
|
|
|
|
main() |