Cody

Solution 1949765

Submitted on 26 Sep 2019 by Pedro
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
M=magic(5); y_correct = [9, 24,1,8 ,15; 23 ,21,7,14,16; ... 4,6,13,20,22; 10,12,19,5,3; 11,18,25,2,17]; assert(isequal(flipDiagonal(M),y_correct))

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

2   Pass
M=magic(2); y_correct=[2 3; 4 1]; assert(isequal(flipDiagonal(M),y_correct))

ans = (1,1) 2 (2,1) 4 (1,2) 3 (2,2) 1

3   Pass
M=ones(4); M(2,2)=4; M(3,3)=9; M(4,4)=16; y_correct=ones(4); y_correct(1,1)=16; y_correct(2,2)=9; y_correct(3,3)=4; assert(isequal(flipDiagonal(M),y_correct))

ans = (1,1) 16 (2,1) 1 (3,1) 1 (4,1) 1 (1,2) 1 (2,2) 9 (3,2) 1 (4,2) 1 (1,3) 1 (2,3) 1 (3,3) 4 (4,3) 1 (1,4) 1 (2,4) 1 (3,4) 1 (4,4) 1

4   Pass
M=[1]; y_correct=[1]; assert(isequal(flipDiagonal(M),y_correct))

ans = (1,1) 1

5   Pass
M=reshape(1:25,[5,5]); y_correct=[25 2 3 4 5; 6 19 8 9 10; ... 11 12 13 14 15; 16 17 18 7 20; 21 22 23 24 1]'; assert(isequal(flipDiagonal(M),y_correct))

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

6   Pass
M=[1,1,1,1;2,2,2,2;3,3,3,3;4,4,4,4]; y_correct=[4,1,1,1;2,3,2,2;3,3,2,3;4,4,4,1]; assert(isequal(flipDiagonal(M),y_correct))

ans = (1,1) 4 (2,1) 2 (3,1) 3 (4,1) 4 (1,2) 1 (2,2) 3 (3,2) 3 (4,2) 4 (1,3) 1 (2,3) 2 (3,3) 2 (4,3) 4 (1,4) 1 (2,4) 2 (3,4) 3 (4,4) 1