0
How to print permutations without itertools and recursive calls ?
to achieve this my friend suggested me this logic.. rotate the string and then print it and swap the characters with another.. example : input is "abc" rotating : cab bca abc now swapping the first character with second so now our new string becomes 'bac' again rotating cba acb bac like this i got permutations! but what if the length of the input is greater than 3 ? I tried to achive my goal with 4 length of string with the same logic.. but I am getting 4 duplicate values as output instead of real permutations. how to solve this problem? my attempt : https://code.sololearn.com/cw44n4fGvSWu/?ref=app
4 ответов
+ 2
Nick I want all possible permutations...like I described in description..
for "abcd" their are 24 possible permutations (non repeated)
nPr=n!
------
(n-r)!
+ 1
Finally haha https://code.sololearn.com/c3g8IdDvv6zJ/?ref=app
0
Do you want all the possible combinations or there's certain rules to it?