Cody

Solution 1840657

Submitted on 6 Jun 2019
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   Fail
v = [1, 2, 3, 4, 5, 6, 7, 8]; n = 1; w_correct = 8 : -1 : 1; assert(isequal(shuffle(v, n), w_correct))

Undefined function or variable 'v1'. Error in shuffle>push (line 20) if size(v1,1)==0 %v is an empty vec Error in shuffle (line 8) b=push(b,c);%arrange the last arranged elements with second part Error in Test2 (line 4) assert(isequal(shuffle(v, n), w_correct))

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

Undefined function or variable 'v1'. Error in shuffle>push (line 20) if size(v1,1)==0 %v is an empty vec Error in shuffle (line 8) b=push(b,c);%arrange the last arranged elements with second part Error in Test3 (line 4) assert(isequal(shuffle(v, n), w_correct))

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

Undefined function or variable 'v1'. Error in shuffle>push (line 20) if size(v1,1)==0 %v is an empty vec Error in shuffle (line 8) b=push(b,c);%arrange the last arranged elements with second part Error in Test4 (line 4) assert(isequal(shuffle(v, n), w_correct))

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

Undefined function or variable 'v1'. Error in shuffle>push (line 20) if size(v1,1)==0 %v is an empty vec Error in shuffle (line 10) d=push(b,a);%the last arrange Error in Test5 (line 4) assert(isequal(shuffle(v, n), w_correct))

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

Undefined function or variable 'v1'. Error in shuffle>push (line 20) if size(v1,1)==0 %v is an empty vec Error in shuffle (line 10) d=push(b,a);%the last arrange Error in Test6 (line 4) assert(isequal(shuffle(v, n), w_correct))

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

Undefined function or variable 'v1'. Error in shuffle>push (line 20) if size(v1,1)==0 %v is an empty vec Error in shuffle (line 10) d=push(b,a);%the last arrange Error in Test7 (line 4) assert(isequal(shuffle(v, n), w_correct))

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

Undefined function or variable 'v1'. Error in shuffle>push (line 20) if size(v1,1)==0 %v is an empty vec Error in shuffle (line 10) d=push(b,a);%the last arrange Error in Test8 (line 4) assert(isequal(shuffle(v, n), w_correct))

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

Undefined function or variable 'v1'. Error in shuffle>push (line 20) if size(v1,1)==0 %v is an empty vec Error in shuffle (line 10) d=push(b,a);%the last arrange Error in Test9 (line 4) assert(isequal(shuffle(v, n), w_correct))

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

Array indices must be positive integers or logical values. Error in shuffle>pop (line 45) b=[v(end-n+1:end)];% the vec with last n elements Error in shuffle (line 4) [a,b]=pop(v,n);%split the vec to 2 parts when Error in Test10 (line 4) assert(isequal(shuffle(v, n), w_correct))

Suggested Problems

More from this Author25