- I have a string that is made out of Xs and Ys.
For the sake of the question let's say this string is constructed of Four-Xs and Two-Ys:
XXYYYY
How can I generate all of the possible unique strings that are made out of Four-Xs and Two-Ys given that the string is not considered unique if by looping (/rotating/shifting) its characters around it produces a string that was already found?
For instance:
XXYYYY is considered similar to YXXYYY and YYYXXY (cardinal numbers added clarify)
123456 612345 456123
Notice: that the order of the characters stays unchanged, the only thing that changed is the starting character (The original string starts with 1, the 2nd string with 6, and the 3rd with 4, but they all keep the order).
In the case of Two-Xs and Four-Ys (our example) all the possible permutations that are unique are:
XXYYYY
XYXYYY
XYYXYY
And every other order would be a shifted version of one of those 3.
How would you generate all of the possible permutation of a string with and N number of Xs and an M number of Ys?