Search for question
Question

Part B: Shuffling

(8) 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 as described in the lecture notes. For example: an input of range (9)

should output (6,3,0,7,4,1, 8,5,2).

(9) 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.

(10) Write a function period (m) which takes as input a number m (which we will always

take as a multiple of 3) and outputs the smallest positive integer n so that

triple_riffle_repeat (list (range (m)),n) == list (range (m)).

(11) Discuss, with evidence, the outputs of your function period for different values of

m, writing your answer as a comment.