Cody

Solution 2365683

Submitted on 25 May 2020
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 r = 8 e = 1 v = 1 2 3 4 5 6 vector = 1 2 3 4 5 6 q = 7 r = 8 7 e = 2 v = 1 2 3 4 5 vector = 1 2 3 4 5 q = 6 r = 8 7 6 e = 3 v = 1 2 3 4 vector = 1 2 3 4 q = 5 r = 8 7 6 5 e = 4 v = 1 2 3 vector = 1 2 3 q = 4 r = 8 7 6 5 4 e = 5 v = 1 2 vector = 1 2 q = 3 r = 8 7 6 5 4 3 e = 6 v = 1 vector = 1 q = 2 r = 8 7 6 5 4 3 2 e = 7 v = 1×0 empty double row vector vector = 1×0 empty double row vector q = 1 r = 8 7 6 5 4 3 2 1 e = 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 r = 7 8 e = 2 v = 1 2 3 4 vector = 1 2 3 4 q = 5 6 r = 7 8 5 6 e = 4 v = 1 2 vector = 1 2 q = 3 4 r = 7 8 5 6 3 4 e = 6 v = 0×1 empty double column vector vector = 0×1 empty double column vector q = 1 2 r = 7 8 5 6 3 4 1 2 e = 8

4   Fail
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 r = 6 7 8 e = 3 v = 1 2 vector = 1 2 q = 3 4 5 r = 6 7 8 3 4 5 e = 6

Assertion failed.

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

6   Fail
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 r = 4 5 6 7 8 e = 5

Assertion failed.

7   Fail
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 r = 3 4 5 6 7 8 e = 6

Assertion failed.

8   Fail
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 r = 2 3 4 5 6 7 8 e = 7

Assertion failed.

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 r = 1 2 3 4 5 6 7 8 e = 8

10   Fail
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))

Assertion failed.