Cody

Problem 512. Spot the rectangle

Solution 2192078

Submitted on 4 Apr 2020 by Mitchell Hayes
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 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 1 0 0 1 0 0 ]; tf = false; assert(isequal(has_rectangle(a),tf))

R = 5 C = 5

2   Pass
a = [ 1 0 1 0 0 0 1 0 1 0 1 0 0 0 1 1 ]; tf = true; assert(isequal(has_rectangle(a),tf))

R = 4 C = 4

3   Pass
a = [ 1 0 1 0 0 0 1 1 0 0 1 1 ]; tf = true; assert(isequal(has_rectangle(a),tf))

R = 3 C = 4

4   Pass
a = [ 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 1 0 ]; tf = true; assert(isequal(has_rectangle(a),tf))

R = 3 C = 9

5   Pass
a = zeros(20); tf = false; assert(isequal(has_rectangle(a),tf))

R = 20 C = 20

6   Pass
a = ones(9); tf = true; assert(isequal(has_rectangle(a),tf))

R = 9 C = 9

7   Pass
a = double(magic(6)<9); tf = false; assert(isequal(has_rectangle(a),tf))

R = 6 C = 6

Suggested Problems

More from this Author50

Community Treasure Hunt

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

Start Hunting!