Cody

Solution 374261

Submitted on 24 Dec 2013 by Mehmet E. Yavuz
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))

z = 35 3 31 8 30 4 1 32 9 28 5 36 6 7 2 33 34 29 26 21 22 17 12 13 19 23 27 10 14 18 24 25 20 15 16 11

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

z = 92 98 4 85 86 17 23 79 10 11 99 80 81 87 93 24 5 6 12 18 1 7 88 19 25 76 82 13 94 100 8 14 20 21 2 83 89 95 96 77 15 16 22 3 9 90 91 97 78 84 67 73 54 60 61 42 48 29 35 36 74 55 56 62 68 49 30 31 37 43 51 57 63 69 75 26 32 38 44 50 58 64 70 71 52 33 39 45 46 27 40 41 47 28 34 65 66 72 53 59

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

z = 68 80 92 104 116 7 19 31 43 55 56 81 93 105 117 8 20 32 44 45 57 69 94 106 118 9 21 33 34 46 58 70 82 107 119 10 22 23 35 47 59 71 83 95 120 11 12 24 36 48 60 72 84 96 108 1 13 25 37 49 61 73 85 97 109 121 14 26 38 50 62 74 86 98 110 111 2 27 39 51 63 75 87 99 100 112 3 15 40 52 64 76 88 89 101 113 4 16 28 53 65 77 78 90 102 114 5 17 29 41 66 67 79 91 103 115 6 18 30 42 54

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

z = 1 4 2 2 4 8 3 6 9

Suggested Problems

More from this Author1