Cody

# Problem 314. Find the sum of the elements in the "second" diagonal

Solution 116928

Submitted on 21 Jul 2012 by Dimosthenis
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
%% x = magic(6); y_correct = 111; assert(isequal(sum_of_sec_diag(x),y_correct))

sz = 6 6 c = 24 c = 24 23 c = 24 23 22 c = 24 23 22 33 c = 24 23 22 33 5 c = 24 23 22 33 5 4

2   Pass
%% x = magic(10); y_correct = 505; assert(isequal(sum_of_sec_diag(x),y_correct))

sz = 10 10 c = 40 c = 40 64 c = 40 64 63 c = 40 64 63 62 c = 40 64 63 62 61 c = 40 64 63 62 61 90 c = 40 64 63 62 61 90 89 c = 40 64 63 62 61 90 89 13 c = 40 64 63 62 61 90 89 13 12 c = 40 64 63 62 61 90 89 13 12 11

3   Pass
%% x = magic(11); y_correct = 671; assert(isequal(sum_of_sec_diag(x),y_correct))

sz = 11 11 c = 66 c = 66 65 c = 66 65 64 c = 66 65 64 63 c = 66 65 64 63 62 c = 66 65 64 63 62 61 c = 66 65 64 63 62 61 60 c = 66 65 64 63 62 61 60 59 c = 66 65 64 63 62 61 60 59 58 c = 66 65 64 63 62 61 60 59 58 57 c = Columns 1 through 10 66 65 64 63 62 61 60 59 58 57 Column 11 56

4   Pass
%% x=[1 2 3; 4 4 6; 2 8 9]; y_correct = 9; assert(isequal(sum_of_sec_diag(x),y_correct))

sz = 3 3 c = 3 c = 3 4 c = 3 4 2