Cody

# Problem 32. Most nonzero elements in row

Solution 2020298

Submitted on 14 Nov 2019 by kristie moore
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 = [ ... 1 2 0 0 0 0 0 5 0 0 2 7 0 0 0 0 6 9 3 3]; r_correct = 4; assert(isequal(fullest_row(a),r_correct))

j = 1 m = 4 n = 5 i = 0 0 0 0 i = 1 0 0 0 i = 3 0 0 0 i = 3 0 0 0 i = 3 0 0 0 i = 3 0 0 0 j = 2 i = 3 0 0 0 i = 3 0 0 0 i = 3 5 0 0 i = 3 5 0 0 i = 3 5 0 0 j = 3 i = 3 5 2 0 i = 3 5 9 0 i = 3 5 9 0 i = 3 5 9 0 i = 3 5 9 0 j = 4 i = 3 5 9 0 i = 3 5 9 6 i = 3 5 9 15 i = 3 5 9 18 i = 3 5 9 21 j = 5 M = 21 I = 4 r = 4

2   Pass
a = [ ... 1 2 0 0 0 0 5 0 0 6 9 -3 2 7 0 0 0 0 0 0]; r_correct = 3; assert(isequal(fullest_row(a),r_correct))

j = 1 m = 5 n = 4 i = 0 0 0 0 0 i = 1 0 0 0 0 i = 3 0 0 0 0 i = 3 0 0 0 0 i = 3 0 0 0 0 j = 2 i = 3 0 0 0 0 i = 3 0 0 0 0 i = 3 5 0 0 0 i = 3 5 0 0 0 j = 3 i = 3 5 0 0 0 i = 3 5 6 0 0 i = 3 5 15 0 0 i = 3 5 12 0 0 j = 4 i = 3 5 12 2 0 i = 3 5 12 9 0 i = 3 5 12 9 0 i = 3 5 12 9 0 j = 5 i = 3 5 12 9 0 i = 3 5 12 9 0 i = 3 5 12 9 0 i = 3 5 12 9 0 j = 6 M = 12 I = 3 r = 3

3   Pass
a = [ ... 1 0 0 0 0 0 0 0 0 0 0 0 0 2 3]; r_correct = 5; assert(isequal(fullest_row(a),r_correct))

j = 1 m = 5 n = 3 i = 0 0 0 0 0 i = 1 0 0 0 0 i = 1 0 0 0 0 i = 1 0 0 0 0 j = 2 i = 1 0 0 0 0 i = 1 0 0 0 0 i = 1 0 0 0 0 j = 3 i = 1 0 0 0 0 i = 1 0 0 0 0 i = 1 0 0 0 0 j = 4 i = 1 0 0 0 0 i = 1 0 0 0 0 i = 1 0 0 0 0 j = 5 i = 1 0 0 0 0 i = 1 0 0 0 2 i = 1 0 0 0 5 j = 6 M = 5 I = 5 r = 5

4   Pass
a = [ ... 0 0 0 -3 0 0]; r_correct = 4; assert(isequal(fullest_row(a),r_correct))

j = 1 m = 6 n = 1 i = 0 0 0 0 0 0 i = 0 0 0 0 0 0 j = 2 i = 0 0 0 0 0 0 j = 3 i = 0 0 0 0 0 0 j = 4 i = 0 0 0 3 0 0 j = 5 i = 0 0 0 3 0 0 j = 6 i = 0 0 0 3 0 0 j = 7 M = 3 I = 4 r = 4