algorithm - Permutation of all the characters when few characters are always together -
i trying obtain permutation of characters in string lets 'kiran'. can use :
perms('kiran')
this returns permutation of character in string factorial(5)=120. now, looking obtain, permutation of string when characters 'ira' together.
the answer factorial(3) = 6.
i write module returns permutation of characters, 'ira' together.
any idea how programmatically obtain in matlab?
thanks
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)
Comments
Post a Comment