Ouputting all the permutations with repeated symbols in MATLAB

1 visualización (últimos 30 días)
Mason Dyess
Mason Dyess el 14 de Ag. de 2019
Comentada: KSSV el 14 de Ag. de 2019
Hi, so I have a problem that's very similar to the classic "Mississippi" permutations problem. That is, "How many different linear arrangements of the letters from the word, 'Mississippi' are there?" I know how to do the actual calculation to find this, you would just do the 11!/(2!*4!*4!*1!) = 34,650. My question is, is there a way where you could have MATLAB generate all of these 34,650 possible arrangements, not just calculate the number 34,650?

Respuesta aceptada

KSSV
KSSV el 14 de Ag. de 2019
Editada: KSSV el 14 de Ag. de 2019
Read about perms. After this, you can try unique and get the required output.
str = 'Mississippi' ;
S = perms(str) ;
iwant = unique(S,'rows') ; % output would be exactly 34650
  2 comentarios
Mason Dyess
Mason Dyess el 14 de Ag. de 2019
Thank you KSSV, this was very helpful. One more thing, if I wanted to apply this same concept to a lengthy number string, (Ex: [1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]) how would I do this? I tried perms, but the length of that vector exceeds the limit for the input you can do. I'm really just interested in seeing all the ways you could arrange the nonzero values in the vector.
KSSV
KSSV el 14 de Ag. de 2019
This is a huge input to achive the same.....

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Discrete Math en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by