I bought three boxes of tea bags with different flavors (A, B, C).
I wish to mix them in such a way that - there is never two consecutive bags of the same flavor (ABCCAB is avoided) ; - the mixing is the "most" random, i.e. avoid patterns such as ABCABCABC... or ABABAB...BCBCBC...CACACA.
Is there a known algorithm for this mix?
Presently I randomly shuffle many "ABC" and concatenate the results, swapping the first letters if the latest letter of the previous shuffle is the same than the beginning of the new shuffle (...ABCCAB => ...ABCACB).
I guess I could improve this algorithm by pre-computing the permutations of ABC, and draw one permutation among the ones who do not begin with the same letter than the previous permutation.
I tried to "google" this problem but as a French native speaker, I probably miss the appropriate key-words.