Cody

Solution 1570820

Submitted on 28 Jun 2018
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   Fail
x = 1; y_correct = 1; assert(isequal(flip_columns(x),y_correct))

Index in position 2 exceeds array bounds (must not exceed 1). Error in flip_columns (line 5) y(:, [c c+1]) = x(:, [c+1 c]) Error in Test1 (line 3) assert(isequal(flip_columns(x),y_correct))

2   Fail
x = 1:5; y_correct = [2 1 4 3 5]; assert(isequal(flip_columns(x),y_correct))

y = 2 1 3 4 5 y = 2 1 4 3 5

Index in position 2 exceeds array bounds (must not exceed 5). Error in flip_columns (line 5) y(:, [c c+1]) = x(:, [c+1 c]) Error in Test2 (line 3) assert(isequal(flip_columns(x),y_correct))

3   Fail
x = [1 2 3 4 5]; y_correct = [2 1 4 3 5]; assert(isequal(flip_columns(x),y_correct))

y = 2 1 3 4 5 y = 2 1 4 3 5

Index in position 2 exceeds array bounds (must not exceed 5). Error in flip_columns (line 5) y(:, [c c+1]) = x(:, [c+1 c]) Error in Test3 (line 3) assert(isequal(flip_columns(x),y_correct))

4   Pass
x = eye(4); y_correct = [0 1 0 0; 1 0 0 0; 0 0 0 1; 0 0 1 0]; assert(isequal(flip_columns(x),y_correct))

y = 0 1 0 0 1 0 0 0 0 0 1 0 0 0 0 1 y = 0 1 0 0 1 0 0 0 0 0 0 1 0 0 1 0

5   Fail
x = magic(5); y_correct = [24 17 8 1 15; ... 5 23 14 7 16; ... 6 4 20 13 22; ... 12 10 21 19 3; ... 18 11 2 25 9]; assert(isequal(flip_columns(x),y_correct))

y = 24 17 1 8 15 5 23 7 14 16 6 4 13 20 22 12 10 19 21 3 18 11 25 2 9 y = 24 17 8 1 15 5 23 14 7 16 6 4 20 13 22 12 10 21 19 3 18 11 2 25 9

Index in position 2 exceeds array bounds (must not exceed 5). Error in flip_columns (line 5) y(:, [c c+1]) = x(:, [c+1 c]) Error in Test5 (line 7) assert(isequal(flip_columns(x),y_correct))