Cody

Solution 1910294

Submitted on 23 Aug 2019 by Eugene Avrutin
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 0; 0 0]; [r1,r2,c1,c2] = biggest_box(a); sub = a(r1:r2,c1:c2); [m,n] = size(sub); len = 1; assert(isequal(sum(sub(:)),0)) assert(isequal(m,len)); assert(isequal(n,len));

1 0 0 0 r1 = 1 r2 = 1 c1 = 1 c2 = 1 done = logical 0 z = 2 z = 1 r1 = 2 r2 = 2 c1 = 1 c2 = 1 done = logical 1

2   Pass
a = [1 0 0; 0 0 0; 0 0 0]; [r1,r2,c1,c2] = biggest_box(a); sub = a(r1:r2,c1:c2); [m,n] = size(sub); len = 2; assert(isequal(sum(sub(:)),0)) assert(isequal(m,len)); assert(isequal(n,len));

1 0 0 0 0 0 0 0 0 r1 = 1 r2 = 1 c1 = 1 c2 = 1 done = logical 0 z = 3 z = 2 r1 = 2 r2 = 3 c1 = 1 c2 = 2 done = logical 1

3   Pass
a = eye(9); [r1,r2,c1,c2] = biggest_box(a); sub = a(r1:r2,c1:c2); [m,n] = size(sub); len = 4; assert(isequal(sum(sub(:)),0)) assert(isequal(m,len)); assert(isequal(n,len));

1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 r1 = 1 r2 = 1 c1 = 1 c2 = 1 done = logical 0 z = 9 z = 8 z = 7 z = 6 z = 5 z = 4 r1 = 5 r2 = 8 c1 = 1 c2 = 4 done = logical 1

4   Pass
a = double(magic(7)<6); [r1,r2,c1,c2] = biggest_box(a); sub = a(r1:r2,c1:c2); [m,n] = size(sub); len = 4; assert(isequal(sum(sub(:)),0)) assert(isequal(m,len)); assert(isequal(n,len));

0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 r1 = 1 r2 = 1 c1 = 1 c2 = 1 done = logical 0 z = 7 z = 6 z = 5 z = 4 r1 = 2 r2 = 5 c1 = 2 c2 = 5 done = logical 1