Cody

Solution 2246046

Submitted on 30 Apr 2020 by Asif Newaz
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
a =magic(4); b_correct = 6; assert(isequal(CountNearestDiagonalNonZeros(a),b_correct))

ans = 6

2   Pass
a =[-1 2 0 -6;0 1 2 -15;14 7 0 i;30 -1 0 -2]; b_correct = 4; assert(isequal(CountNearestDiagonalNonZeros(a),b_correct))

ans = 4

3   Pass
a =zeros(6); b_correct = 0; assert(isequal(CountNearestDiagonalNonZeros(a),b_correct))

ans = 0

4   Pass
a =[-4 -3 2 1;-9 0 0 1;1 5 -5 0;2 2 -1 4]; b_correct =4; assert(isequal(CountNearestDiagonalNonZeros(a),b_correct))

ans = 4