pub fn riffle_shuffle<T: Clone>(input: &[T]) -> Vec<T>
Expand description

Performs a perfect shuffle (in shuffle)

https://en.wikipedia.org/wiki/Riffle_shuffle_permutation#Perfect_shuffles https://en.wikipedia.org/wiki/In_shuffle

The number of shuffles required to restore the original order are listed in https://oeis.org/A002326 and https://oeis.org/A002326/list, e.g.:

 2 (n=1):  2
 4 (n=2):  4
 6 (n=3):  3
 8 (n=4):  6
10 (n=5): 10
12 (n=6): 12
14 (n=7):  4
16 (n=8):  8