+ 1
How can I write an algorithm to get all the possible arrangements of the letters in a word?
An algorithm to get all the possible arrangements of all the letters in a word or a list of letters, a possible arrangement of all length (from 1 to the length of the word given)
1 Odpowiedź
+ 4
For example, there is a special module in Python.
from itertools import permutations
word = input()
list = []
for item in permutations(word):
list.append(''.join(item))
print(list)
How it works? Please, read the Heap's Algorithm in Wiki and Docs for this module in Python.org😉