Cody

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

Solution 2930401

Submitted on 9 Sep 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);

z = 14 A = 3.0000 5.0000 7.0000 90.0000 1.0000 5.0000 1.0000 -1.0000 11.3500 2.0000 1.0000 2.0000 3.0000 4.0000 70.0000 23.0000 1.0000 2.0000 3.0000 5.0000

Assertion failed.

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);

z = 9 A = 1.0000 1.0000 2.4500 1.0000 1.0000 2.0000 2.0000 2.0000 2.0000 2.0000 3.0000 3.0000 3.0000 3.0000 3.0000 4.0000 4.0000 4.0000 4.0000 4.0000

Assertion failed.

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);

z = 7 A = 3.0000 3.0000 3.0000 90.0000 2.0000 5.0000 3.0000 -1.0000 6.0000 4.0000 2.0000 13.6000 5.0000 6.0000 80.0000 12.0000 9.0000 12.0000 13.0000 15.0000

Assertion failed.

Suggested Problems

More from this Author2

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!