The question is in bold and the rest is there for support , to explain concepts Write a function triple_riffle(mylist) which takes as input a list (which for convenience we will always take with length a multiple of 3) and outputs the result of a 3-way riffle shuffle . For example: an input of range(9) should output [6,3,0,7,4,1,8,5,2]. Write a function triple_riffle_repeat(mylist,n) which takes as input a list (again with length a multiple of 3) and outputs the result of doing a 3-way riffle shuffle n times.
The question is in bold and the rest is there for support , to explain concepts
Write a function triple_riffle(mylist) which takes as input a list (which for convenience we will always take with length a multiple of 3) and outputs the result of a 3-way riffle shuffle . For example: an input of range(9) should output [6,3,0,7,4,1,8,5,2].
Write a function triple_riffle_repeat(mylist,n) which takes as input a list (again with length a multiple of 3) and outputs the result of doing a 3-way riffle shuffle n times.
A Faro shuffle is when a deck of cards is split exactly in half and then the two halves are interleaved exactly. There are two versions: an out-shuffle where the card in position 1 stays where it is (and likewise the card in the last position stays there), and an in-shuffle where the card in position 1 moves to position 2 (and the card in last position moves up one). The following code prints the result of a Faro out-shuffle on the list [1,2,...,52].
Step by step
Solved in 4 steps with 2 images