Cody

# Problem 44491. Shuffle

Solution 2837919

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

x = 1 2 3 4 5 6 7 y = 8 cetvor = 1 2 3 4 5 6 7 8

Assertion failed.

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

x = 1 2 3 4 5 6 y = 7 8 cetvor = 1 2 3 4 5 6 7 8

Assertion failed.

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

x = 1 2 3 4 5 y = 6 7 8 cetvor = 1 2 3 4 5 6 7 8

Assertion failed.

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

x = 1 2 3 4 y = 5 6 7 8 cetvor = 1 2 3 4 5 6 7 8

Assertion failed.

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

x = 1 2 3 y = 4 5 6 7 8 cetvor = 1 2 3 4 5 6 7 8

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

x = 1 2 y = 3 4 5 6 7 8 cetvor = 1 2 3 4 5 6 7 8

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

x = 1 y = 2 3 4 5 6 7 8 cetvor = 1 2 3 4 5 6 7 8

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

x = 0×1 empty double column vector y = 1 2 3 4 5 6 7 8 cetvor = 1 2 3 4 5 6 7 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))

x = 1×0 empty double row vector y = 1 2 3 4 5 6 7 8 cetvor = 1 2 3 4 5 6 7 8

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!