x={'K','IRA','N'}
%one permutation per row
y=x(perms(1:numel(x)))
%concatinate rows
y=arrayfun(@(x)[y{x,:}],1:size(y,1),'UniformOutput',false)
Permutation of all the characters when few characters are always together
-
28-06-2023 - |
Question
I am trying to obtain the permutation of all characters in a string lets say 'KIRAN'. I can use :
perms('KIRAN')
This returns a permutation of all the character in the string which factorial(5)=120. Now, I am looking to obtain, the permutation of the string when the characters 'IRA' are always together.
The answer is factorial(3) = 6.
I would like to write a module which returns the permutation of all the characters, where 'IRA' are always together.
Any idea how to programmatically obtain it in Matlab?
Thanks
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow