Problem 514. Spot the rectangle (Part 2)
This problem is related to the 17x17 challenge. See also Part 1 of this problem. Given a matrix in which each element is either 1, 2, 3, or 4, determine whether or not any rectangles are present. A rectangle is a formed whenever four instances of the same value appear in the corners of a rectangular region of the matrix.
Examples:
Input a = [ 4 1 2 4 1
3 3 2 1 4
3 2 4 1 1
1 4 3 2 2
1 1 1 4 4 ]
Output tf is false
You can't form any rectangles here.
Input a = [ 1 4 3 1
3 1 4 1
1 3 4 1
1 1 2 3 ]
Output tf is true
There is a rectangle: a([1 3],[1 4]) is [1 1; 1 1]
Solution Stats
Problem Comments
-
1 Comment
Abdelrahman Adel
on 7 Apr 2024 at 12:56
it was a good problem.
Here is my m File Solution : http://up-4.net/d/tt7S
Solution Comments
Show commentsProblem Recent Solvers88
Suggested Problems
-
The Hitchhiker's Guide to MATLAB
3245 Solvers
-
20530 Solvers
-
Solve the set of simultaneous linear equations
395 Solvers
-
Create Volcano (or Atoll) martix. It is an extension of Bullseye matrix problem.
135 Solvers
-
Remove element(s) from cell array
1341 Solvers
More from this Author50
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!