Cody

# Problem 44491. Shuffle

Solution 2428475

Submitted on 30 May 2020 by matan arviv
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 vector = 1 2 3 4 5 6 7 q = 8 t = 8 j = 1 v = 1 2 3 4 5 6 vector = 1 2 3 4 5 6 q = 7 t = 8 7 j = 2 v = 1 2 3 4 5 vector = 1 2 3 4 5 q = 6 t = 8 7 6 j = 3 v = 1 2 3 4 vector = 1 2 3 4 q = 5 t = 8 7 6 5 j = 4 v = 1 2 3 vector = 1 2 3 q = 4 t = 8 7 6 5 4 j = 5 v = 1 2 vector = 1 2 q = 3 t = 8 7 6 5 4 3 j = 6 v = 1 vector = 1 q = 2 t = 8 7 6 5 4 3 2 j = 7 v = 1×0 empty double row vector vector = 1×0 empty double row vector q = 1 t = 8 7 6 5 4 3 2 1 j = 8

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 vector = 1 2 3 4 5 6 q = 7 8 t = 7 8 j = 2 v = 1 2 3 4 vector = 1 2 3 4 q = 5 6 t = 7 8 5 6 j = 4 v = 1 2 vector = 1 2 q = 3 4 t = 7 8 5 6 3 4 j = 6 v = 0×1 empty double column vector vector = 0×1 empty double column vector q = 1 2 t = 7 8 5 6 3 4 1 2 j = 8

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 vector = 1 2 3 4 5 q = 6 7 8 t = 6 7 8 j = 3 v = 1 2 vector = 1 2 q = 3 4 5 t = 6 7 8 3 4 5 j = 6

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 vector = 1 2 3 4 q = 5 6 7 8 t = 5 6 7 8 j = 4 v = 0×1 empty double column vector vector = 0×1 empty double column vector q = 1 2 3 4 t = 5 6 7 8 1 2 3 4 j = 8

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 vector = 1 2 3 q = 4 5 6 7 8 t = 4 5 6 7 8 j = 5

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 vector = 1 2 q = 3 4 5 6 7 8 t = 3 4 5 6 7 8 j = 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 vector = 1 q = 2 3 4 5 6 7 8 t = 2 3 4 5 6 7 8 j = 7

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 vector = 0×1 empty double column vector q = 1 2 3 4 5 6 7 8 t = 1 2 3 4 5 6 7 8 j = 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))