dimanche 29 mars 2015

Permutation of S

Let's say I have a row filled with three different strings in different cells, how do I create a permutation algorithm that will generate the following outputs?


Input: Cat Dog Rat


Ouput:


Cat Dog Rat


Cat Rat Dog


Dog Cat Rat


Dog Rat Cat


Rat Dog Cat


Rat Cat Dog


Most of the solutions in the web generate combinations instead of the desired permutations. Also, the solutions I found involved strings in just one cell. i.e.: Cat --> Cat, Cta, Atc, Act, etc etc etc


I hope someone could help me out a bit regarding this - or at least provide a starting point.


Many thanks in advance!


Aucun commentaire:

Enregistrer un commentaire