MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn moreOpportunities for recent engineering grads.

Apply Today**New to MATLAB?**

This problem is related to the 17x17 challenge. Given a matrix filled with ones and zeros, determine whether or not any rectangles are present. A rectangle is a formed whenever four ones appear in the corners of a rectangular region of the matrix.

Examples:

Input 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 ] Output tf is false

You can't form any rectangles here.

Input a = [ 1 0 1 0 0 0 1 0 1 0 1 0 0 0 1 1 ] Output tf is true

There is a rectangle: a([1 3],[1 3]) is [1 1; 1 1]

40 correct solutions
38 incorrect solutions

Last solution submitted on Mar 05, 2015

1 player likes this solution

2 Comments

Ned Gulley
on 21 Mar 2012

This is a good answer. I changed the test suite so that you wouldn't have to deal with logical input matrices. Sorry about that!

Ned Gulley
on 20 Jan 2015

This code is referenced in the following blog post: http://blogs.mathworks.com/community/2015/01/19/robot-game-playing-in-matlab-part-2/

2 Comments