Given a non-empty 2D array consisting of 0
and 1
, find the number of squares whose 4 corners are all 1
. The squares do not need to be "upright". All the rows are guaranteed to have the same length.
Reasonable input/output methods are allowed.
Testcases:
0001000
1000000
0000000
0000100
0100000
This returns 1
.
10101
00000
10100
00000
10001
This returns 2
.
1111
1111
1111
1111
This returns 20
.
This is code-golf. Shortest answer in bytes wins. Standard loopholes apply.
1
s on a square, such that each1
is equidistant along the perimeter from its two neighbors. \$\endgroup\$