Cody

# Problem 44491. Shuffle

Solution 1416922

Submitted on 15 Jan 2018 by Yair Fridman
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
filetext = fileread('shuffle.m'); assert(isempty(strfind(filetext, 'regexp')),'regexp hacks are forbidden')

2   Pass
v = [1, 2, 3, 4, 5, 6, 7, 8]; n = 1; w_correct = 8 : -1 : 1; assert(isequal(shuffle(v, n), w_correct))

v = 1 2 3 4 5 6 7 c = 8 v = 1 2 3 4 5 6 c = 8 7 v = 1 2 3 4 5 c = 8 7 6 v = 1 2 3 4 c = 8 7 6 5 v = 1 2 3 c = 8 7 6 5 4 v = 1 2 c = 8 7 6 5 4 3 v = 1 c = 8 7 6 5 4 3 2 v = 1×0 empty double row vector c = 8 7 6 5 4 3 2 1 n = 1

3   Pass
v = [1; 2; 3; 4; 5; 6; 7; 8]; n = 2; w_correct = [7;8; 5;6; 3;4; 1;2]; assert(isequal(shuffle(v, n), w_correct))

v = 1 2 3 4 5 6 c = 7 8 v = 1 2 3 4 c = 7 5 8 6 v = 1 2 c = 7 5 3 8 6 4 v = 0×1 empty double column vector c = 7 5 3 1 8 6 4 2 n = 2

4   Pass
v = [1, 2, 3, 4, 5, 6, 7, 8]; n = 3; w_correct = [6,7,8, 3,4,5, 1,2]; assert(isequal(shuffle(v, n), w_correct))

v = 1 2 3 4 5 c = 6 7 8 v = 1 2 c = 6 7 8 3 4 5 n = 1

5   Pass
v = [1; 2; 3; 4; 5; 6; 7; 8]; n = 4; w_correct = [5;6;7;8; 1;2;3;4]; assert(isequal(shuffle(v, n), w_correct))

v = 1 2 3 4 c = 5 6 7 8 v = 0×1 empty double column vector c = 5 1 6 2 7 3 8 4 n = 4

6   Pass
v = [1, 2, 3, 4, 5, 6, 7, 8]; n = 5; w_correct = [4,5,6,7,8, 1,2,3]; assert(isequal(shuffle(v, n), w_correct))

v = 1 2 3 c = 4 5 6 7 8 n = 1

7   Pass
v = [1; 2; 3; 4; 5; 6; 7; 8]; n = 6; w_correct = [3;4;5;6;7;8; 1;2]; assert(isequal(shuffle(v, n), w_correct))

v = 1 2 c = 3 4 5 6 7 8 n = 6

8   Pass
v = [1, 2, 3, 4, 5, 6, 7, 8]; n = 7; w_correct = [2,3,4,5,6,7,8, 1]; assert(isequal(shuffle(v, n), w_correct))

v = 1 c = 2 3 4 5 6 7 8 n = 1

9   Pass
v = [1; 2; 3; 4; 5; 6; 7; 8]; n = 8; w_correct = [1;2;3;4;5;6;7;8]; assert(isequal(shuffle(v, n), w_correct))

v = 0×1 empty double column vector c = 1 2 3 4 5 6 7 8 n = 8

10   Pass
v = [1, 2, 3, 4, 5, 6, 7, 8]; n = 9; w_correct = [1,2,3,4,5,6,7,8]; assert(isequal(shuffle(v, n), w_correct))

n = 0