Skip to content

Commit

Permalink
Reto mouredev#16 - Python
Browse files Browse the repository at this point in the history
  • Loading branch information
ycanas committed Oct 25, 2023
1 parent e16a00a commit 96a7ffe
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions Retos/Reto #36 - PERMUTACIONES [Media]/python/ycanas.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
def permute(word):
if len(word) == 1:
return word

permutations = []

for i in range(len(word)):
current = word[i]
rest = word[:i] + word[i + 1:]

_permutations = permute(rest)

for permut in _permutations:
permutations.append(current + permut)

return permutations


permutations = permute("sol")

for permut in permutations:
print(permut)

0 comments on commit 96a7ffe

Please sign in to comment.