Permutation: Interleave...

Generates a new Permutation by interleaving elements from successive blocks.

We always start with the first element in the first block. When the offset is zero, the next element will be the first element of the second block, then the first element of the third block. After the first element of the last block, we start again with the second elements in each block. And so on. (In card playing, with two blocks of 26 cards each, this is called a faro shuffle and eight successive faro shuffles will return the deck to precisely the order in which you began.)

If the offset differs from zero and equals 1 for example, we start with the first element in the first block, then the second element in the second block, the third element in the third block and so on. When the last element of a block is reached and the number of blocks is not exhausted the next element will be the first from the next block. When the last block is reached, we start the same cycle again with the next lower element in the first block (which by the way need not be the second element, see also example 4).

Settings

Index range
the range of elements that will be permuted.
Block size
the size of a block. An integer number of blocks must fit in the chosen Index range.
Offset
determines the relative positions of selected elements in successive blocks.

Examples

1. With Index range = [0,0], Block size = 3, and Offset = 0, the permutation ((1,2,3),(4,5,6),(7,8,9)) is turned into (1,4,7,2,5,8,3,6,9).

2. With Index range = [0,0], Block size = 3, and Offset = 1, the permutation ((1,2,3),(4,5,6),(7,8,9)) is turned into (1,5,9,2,6,7,3,4,8).

3. With Index range = [0,0], Block size = 3, and Offset = 2, the permutation ((1,2,3),(4,5,6),(7,8,9)) is turned into (1,6,8,2,4,9,3,5,7).

4. With Index range = [0,0], Block size = 4, and Offset = 1, the permutation ((1,2,3,4),(5,6,7,8)) is turned into (1,6,3,8,2,7,4,5).


© djmw 20110105