Eg: Grid of size $3\times3$ can have $4$ sub-grid of size $2 \times 2$ and $6$ sub-grid of size $1 \times2$.
Is there any formula to calculate the total number of possible sub-grid of a given size $A\times B$ in a Grid of size $N \times M$?
Eg: Grid of size $3\times3$ can have $4$ sub-grid of size $2 \times 2$ and $6$ sub-grid of size $1 \times2$.
Is there any formula to calculate the total number of possible sub-grid of a given size $A\times B$ in a Grid of size $N \times M$?
Copyright © 2021 JogjaFile Inc.
You can simply put an $A \times B$ grid to top left of $N \times M$ grid and then shift it rightwards until the end. Then, you can shift it $1$ square downwards each time you get to the end and do the same. With this algorithm, you can scan all of the $N \times M$ grid. This gives a formula $$(N-A+1)(M-B+1)$$
This was just to give you the idea to derive the formula. You can come up with an argument that doesn't need to use an algorithm.