Wow! Size 10.
@Informaton: Oh, it's nothing; just a cheating script ("gaming the test suite answers") combined with the well-known 'regexp' trick. A proper small solution was first submitted by Tim (Solution 97452 - size:51) and was later optimized in size by Alfonso Nieto-Castanon (Solution 181060 - size:48). My alternative Solution 1198643 (size:63), which uses for-loops instead of conv2 or filter2 function, is also much better than this 'regexp' cheat.
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));
|
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));
|
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));
|
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));
|
19329 Solvers
579 Solvers
Create a two dimensional zero matrix
354 Solvers
238 Solvers
Deleting an element in a matrix
325 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!