Problem 56478. IQpuzzler Preparation #3: Detect isolated groups of zeros in a matrix

Return true if any small, rectangular shaped, isolated groups of zeros (size 1x1, 1x2, 2x1, 1x3, 3x1 or 2x2) are present in a matrix, with all vertically and horizontally adjacent elements being non-zero.
The matrix will always be 3-by-3 or larger.
Examples:
11 2 3 2 9 10 10 11 6 7 4
12 4 13 6 1 10 1 10 5 6 9
2 8 13 12 0 0 0 5 10 9 9
12 13 7 11 13 9 1 13 11 10 3
9 13 11 13 9 3 2 1 3 10 2
==> true
11 2 3 2 9 10 10 11 6 7 4
12 4 13 6 1 10 1 10 5 6 9
2 8 13 12 0 0 0 1 10 9 9
12 13 7 11 13 0 1 13 11 10 3
9 13 11 13 9 3 2 1 3 10 2
==> false
7 10 13 11 5 5 4 1 2 3 8
13 0 8 4 3 11 10 1 8 11 4
5 0 2 11 4 8 10 7 7 5 9
8 0 2 4 9 8 5 11 1 7 9
3 12 4 13 7 12 8 13 5 3 10
==> true
Background:
This function or variations of it may be useful in some board games like Go, or in the upcoming IQpuzzler challenge.
Hint:
The built-in function conv2 may be helpful for your implementation.

Solution Stats

71.43% Correct | 28.57% Incorrect
Last Solution submitted on Aug 03, 2023

Problem Comments

Solution Comments

Show comments

Problem Recent Solvers4

Suggested Problems

More from this Author5

Problem Tags

Community Treasure Hunt

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

Start Hunting!