Cody

# Problem 2234. Find and replace the zero array in a matrix

Solution 2727147

Submitted on 22 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
A=[3,5,7,90,1;5,1,-1,0,2;1,2,3,4,70;23,1,2,3,5]; B= 23.75; tolerance = 1e-2 ; assert(abs(adjacent_averaging(A)-B)<tolerance);

Error using sum Invalid option. Option must be 'double', 'native', 'default', 'omitnan', or 'includenan'. Error in adjacent_averaging (line 3) A(ii,jj)=sum(A(ii+1,jj),A(ii-1,jj),A(ii,jj-1),A(ii,jj+1))/4; Error in Test1 (line 4) assert(abs(adjacent_averaging(A)-B)<tolerance);

2   Fail
A=[1,1,0,1,1;2,2,2,2,2;3,3,3,3,3;4,4,4,4,4]; B= 1.3333; tolerance = 1e-2 ; assert(abs(adjacent_averaging(A)-B)<tolerance);

Index in position 1 is invalid. Array indices must be positive integers or logical values. Error in adjacent_averaging (line 3) A(ii,jj)=sum(A(ii+1,jj),A(ii-1,jj),A(ii,jj-1),A(ii,jj+1))/4; Error in Test2 (line 4) assert(abs(adjacent_averaging(A)-B)<tolerance);

3   Fail
A=[3,3,3,90,2;5,3,-1,6,4;2,0,5,6,80;12,9,12,13,15]; B= 4.75; tolerance = 1e-2 ; assert(abs(adjacent_averaging(A)-B)<tolerance);

Error using sum Invalid option. Option must be 'double', 'native', 'default', 'omitnan', or 'includenan'. Error in adjacent_averaging (line 3) A(ii,jj)=sum(A(ii+1,jj),A(ii-1,jj),A(ii,jj-1),A(ii,jj+1))/4; Error in Test3 (line 4) assert(abs(adjacent_averaging(A)-B)<tolerance);