circular-permutations

Generating all unique orders of looping series of characters (all circular permutations)

笑着哭i 提交于 2019-12-11 18:23:39
问题 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