Cody

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

Solution 2758744

Submitted on 30 Jul 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   Fail
x = magic(6); y_correct = 111; assert(isequal(sum_of_sec_diag(x),y_correct))

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

Assertion failed.

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

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

Assertion failed.

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

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

Assertion failed.

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

m = 3 3 h = 0 a = 1 2 3 a = 4 4 6 a = 2 8 9 y = 9 9

Assertion failed.

Suggested Problems

More from this Author1