recursion - Combinatorics in Scala: How to iterate/enumerate all possibilities to merge multiple sequences/lists (riffle shuffle permutations) -
recursion - Combinatorics in Scala: How to iterate/enumerate all possibilities to merge multiple sequences/lists (riffle shuffle permutations) - updated question: in original question did not know how refer next problem. clarify question, added following illustration wikipedia: it turns out problem named after analogy: riffle shuffle permutations. based on terminology question becomes: how can iterate/enumerate riffle shuffle permutations in general case of multiple decks? original question: let's assume given multiple sequences , want merge these sequences 1 single sequence. resulting sequence should preserve order of original sequences. think of merging multiple stacks of cards (say seq[seq[t]] ) 1 single stack ( seq[t] ) randomly drawing card (random) stack. input stacks should merged resulting stack. how can iterate or enumerate possible compositions of such resulting sequence? to clarify: if have 3 stacks a, b, c (of 5 elements each) not want 6 possible arrange