Cody

Solution 1027996

Submitted on 23 Oct 2016 by Brian Lause
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));

ans = 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 s = 2 go c2 = 1 d = [] go c2 = 1 0 0 0 d = 2 3 4 c1 = 2 r1 = 1 r2 = 1 c2 = 2

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

ans = 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 s = 3 go c2 = 1 d = [] go c2 = 1 0 0 0 d = 2 3 4 c1 = 2 r1 = 1 r2 = 2 c2 = 3

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

ans = 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 s = 9 go c2 = 9 d = [] go c2 = 8 7 7 8 d = 0×1 empty double column vector go c2 = 7 6 5 6 7 6 5 6 7 d = 0×1 empty double column vector go c2 = 6 5 4 3 5 6 5 4 4 5 6 5 3 4 5 6 d = 0×1 empty double column vector go c2 = 5 4 3 2 1 4 5 4 3 2 3 4 5 4 3 2 3 4 5 4 1 2 3 4 5 d = 0×1 empty double column vector go c2 = 4 3 2 1 0 0 3 4 3 2 1 0 2 3 4 3 2 1 1 2 3 4 3 2 0 1 2 3 4 3 0 0 1 2 3 4 d = 5 6 12 25 31 32 c1 = 5 r1 = 1 r2 = 4 c2 = 8

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

ans = 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 s = 7 go c2 = 5 d = [] go c2 = 3 3 3 3 d = 0×1 empty double column vector go c2 = 2 1 2 1 1 2 2 2 3 d = 0×1 empty double column vector go c2 = 2 1 1 1 1 0 0 1 1 0 1 2 1 1 2 3 d = 6 7 10 c1 = 2 r1 = 2 r2 = 5 c2 = 5