quick method to count the number of square

1.6k Views Asked by At

sometimes there are puzzles where you have to give the number of squares you see in a picture, typically an intersection of squares. Is there a fast method to find it based on the number of corners and intersections?

2

There are 2 best solutions below

0
On BEST ANSWER

In a $m \times n$ grid, $m,n \in \mathbb{N}$ and $m>n$,number of squares of all possible dimensions is given by $$ \sum _{i=1}^{n} (m-i+1) \times (n-i+1)$$ so it is obvious of the case when $m=n$.

If you also want to know the number of rectangles in the same grid,then it is given by $$\binom{m+1}{2} \times \binom{n+1}{2}$$ Since there are $(m+1)$ and $(n+1)$ horizontal and vertical lines respectively and by selecting any two vertical and any two horizontal line we will get a rectangle.

0
On

This is not an answer (complete), but if you are given $n\times n$ chess-board type figure, total number of squares is $$\sum_{k=1}^nk^2=\frac{n(n+1)(2n+1)}{6}$$