Cody

# Problem 658. Find the biggest empty box

Solution 1347495

Submitted on 17 Nov 2017 by David Verrelli
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));

maxLen = 2 maxLen = 1 r1best = 1 r2best = 1 c1best = 2 c2best = 2 maxLen = 1 maxLen = 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));

maxLen = 3 maxLen = 2 r1best = 1 r2best = 1 c1best = 2 c2best = 2 r1best = 1 r2best = 2 c1best = 2 c2best = 3 maxLen = 1 maxLen = 2 maxLen = 2 maxLen = 1 maxLen = 1 maxLen = 1 maxLen = 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));

maxLen = 9 maxLen = 8 r1best = 1 r2best = 1 c1best = 2 c2best = 2 maxLen = 7 r1best = 1 r2best = 2 c1best = 3 c2best = 4 maxLen = 6 r1best = 1 r2best = 3 c1best = 4 c2best = 6 maxLen = 5 r1best = 1 r2best = 4 c1best = 5 c2best = 8 maxLen = 4 maxLen = 3 maxLen = 2 maxLen = 1 maxLen = 8 maxLen = 8 maxLen = 7 maxLen = 6 maxLen = 5 maxLen = 4 maxLen = 3 maxLen = 2 maxLen = 1 maxLen = 7 maxLen = 7 maxLen = 7 maxLen = 6 maxLen = 5 maxLen = 4 maxLen = 3 maxLen = 2 maxLen = 1 maxLen = 6 maxLen = 6 maxLen = 6 maxLen = 6 maxLen = 5 maxLen = 4 maxLen = 3 maxLen = 2 maxLen = 1 maxLen = 5 maxLen = 5 maxLen = 5 maxLen = 5 maxLen = 5 maxLen = 4 maxLen = 3 maxLen = 2 maxLen = 1 maxLen = 4 maxLen = 4 maxLen = 4 maxLen = 4 maxLen = 4 maxLen = 4 maxLen = 3 maxLen = 2 maxLen = 1 maxLen = 3 maxLen = 3 maxLen = 3 maxLen = 3 maxLen = 3 maxLen = 3 maxLen = 3 maxLen = 2 maxLen = 1 maxLen = 2 maxLen = 2 maxLen = 2 maxLen = 2 maxLen = 2 maxLen = 2 maxLen = 2 maxLen = 2 maxLen = 1 maxLen = 1 maxLen = 1 maxLen = 1 maxLen = 1 maxLen = 1 maxLen = 1 maxLen = 1 maxLen = 1 maxLen = 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));

maxLen = 7 r1best = 1 r2best = 1 c1best = 1 c2best = 1 r1best = 1 r2best = 2 c1best = 1 c2best = 2 r1best = 1 r2best = 3 c1best = 1 c2best = 3 maxLen = 6 maxLen = 5 maxLen = 4 maxLen = 3 maxLen = 2 maxLen = 1 maxLen = 6 maxLen = 6 r1best = 2 r2best = 5 c1best = 2 c2best = 5 maxLen = 5 maxLen = 4 maxLen = 3 maxLen = 2 maxLen = 1 maxLen = 5 maxLen = 5 maxLen = 5 maxLen = 4 maxLen = 3 maxLen = 2 maxLen = 1 maxLen = 4 maxLen = 4 maxLen = 4 maxLen = 4 maxLen = 3 maxLen = 2 maxLen = 1 maxLen = 3 maxLen = 3 maxLen = 3 maxLen = 3 maxLen = 3 maxLen = 2 maxLen = 1 maxLen = 2 maxLen = 2 maxLen = 2 maxLen = 2 maxLen = 2 maxLen = 2 maxLen = 1 maxLen = 1 maxLen = 1 maxLen = 1 maxLen = 1 maxLen = 1 maxLen = 1 maxLen = 1