Cody

Solution 1414677

Submitted on 12 Jan 2018 by Dor Greenberg
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))

s = [] b = 8 f = 8 w = 8 v = 1 2 3 4 5 6 7 v = 1 2 3 4 5 6 7 w = 8 s = 8 vector = 1 2 3 4 5 6 7 w = 7 v = 1 2 3 4 5 6 v = 1 2 3 4 5 6 w = 7 s = 8 7 vector = 1 2 3 4 5 6 w = 6 v = 1 2 3 4 5 v = 1 2 3 4 5 w = 6 s = 8 7 6 vector = 1 2 3 4 5 w = 5 v = 1 2 3 4 v = 1 2 3 4 w = 5 s = 8 7 6 5 vector = 1 2 3 4 w = 4 v = 1 2 3 v = 1 2 3 w = 4 s = 8 7 6 5 4 vector = 1 2 3 w = 3 v = 1 2 v = 1 2 w = 3 s = 8 7 6 5 4 3 vector = 1 2 w = 2 v = 1 v = 1 w = 2 s = 8 7 6 5 4 3 2 vector = 1 w = 1 v = 1×0 empty double row vector v = 1×0 empty double row vector w = 1 s = 8 7 6 5 4 3 2 1 vector = 1×0 empty double row vector b = [] b = 8 7 6 5 4 3 2 1 v = 8 7 6 5 4 3 2 1 n = 8 v = 8 7 6 5 4 3 2 1 n = 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))

s = [] b = 8 f = 4 w = 7 8 v = 1 2 3 4 5 6 v = 1 2 3 4 5 6 w = 7 8 s = 7 8 vector = 1 2 3 4 5 6 w = 5 6 v = 1 2 3 4 v = 1 2 3 4 w = 5 6 s = 7 5 8 6 vector = 1 2 3 4 w = 3 4 v = 1 2 v = 1 2 w = 3 4 s = 7 5 3 8 6 4 vector = 1 2 w = 1 2 v = 0×1 empty double column vector v = 0×1 empty double column vector w = 1 2 s = 7 5 3 1 8 6 4 2 vector = 0×1 empty double column vector b = [] b = 7 8 5 6 3 4 1 2 v = 7 8 5 6 3 4 1 2 n = 8 v = 7 8 5 6 3 4 1 2 n = 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))

s = [] b = 8 f = 2 w = 6 7 8 v = 1 2 3 4 5 v = 1 2 3 4 5 w = 6 7 8 s = 6 7 8 vector = 1 2 3 4 5 w = 3 4 5 v = 1 2 v = 1 2 w = 3 4 5 s = 6 7 8 3 4 5 vector = 1 2 b = [] b = 6 7 8 3 4 5 1 2 v = 6 7 8 3 4 5 1 2 n = 8 v = 6 7 8 3 4 5 1 2 n = 8

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

s = [] b = 8 f = 2 w = 5 6 7 8 v = 1 2 3 4 v = 1 2 3 4 w = 5 6 7 8 s = 5 6 7 8 vector = 1 2 3 4 w = 1 2 3 4 v = 0×1 empty double column vector v = 0×1 empty double column vector w = 1 2 3 4 s = 5 1 6 2 7 3 8 4 vector = 0×1 empty double column vector b = [] b = 5 6 7 8 1 2 3 4 v = 5 6 7 8 1 2 3 4 n = 8 v = 5 6 7 8 1 2 3 4 n = 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))

s = [] b = 8 f = 1 w = 4 5 6 7 8 v = 1 2 3 v = 1 2 3 w = 4 5 6 7 8 s = 4 5 6 7 8 vector = 1 2 3 b = [] b = 4 5 6 7 8 1 2 3 v = 4 5 6 7 8 1 2 3 n = 8 v = 4 5 6 7 8 1 2 3 n = 8

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

s = [] b = 8 f = 1 w = 3 4 5 6 7 8 v = 1 2 v = 1 2 w = 3 4 5 6 7 8 s = 3 4 5 6 7 8 vector = 1 2 b = [] b = 3 4 5 6 7 8 1 2 v = 3 4 5 6 7 8 1 2 n = 8 v = 3 4 5 6 7 8 1 2 n = 8

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

s = [] b = 8 f = 1 w = 2 3 4 5 6 7 8 v = 1 v = 1 w = 2 3 4 5 6 7 8 s = 2 3 4 5 6 7 8 vector = 1 b = [] b = 2 3 4 5 6 7 8 1 v = 2 3 4 5 6 7 8 1 n = 8 v = 2 3 4 5 6 7 8 1 n = 8

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

s = [] b = 8 f = 1 w = 1 2 3 4 5 6 7 8 v = 0×1 empty double column vector v = 0×1 empty double column vector w = 1 2 3 4 5 6 7 8 s = 1 2 3 4 5 6 7 8 vector = 0×1 empty double column vector b = [] b = 1 2 3 4 5 6 7 8 v = 1 2 3 4 5 6 7 8 n = 8 v = 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))

s = [] b = 8 f = 0 b = [] b = 1 2 3 4 5 6 7 8 v = 1 2 3 4 5 6 7 8 n = 8 v = 1 2 3 4 5 6 7 8 n = 8

Suggested Problems

More from this Author26