Question: Write a function triple riffle ( mylist ) which takes as input a list ( which for convenience we will always take with length a

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 i the lecture notes. For example: an input of range(9) should output [6,3,0,7,4,1,8,5,2].
(8) 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.
(9) 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)).
(10) Discuss, with evidence, the outputs of your function period for different values of m, writing your answer as a comment.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!