×

# How to Count Rectangles!

Hi there! Me again. *munches*

Sorry, I still haven't finished my hamburger since the last time we count squares, I hope you don't mind that.

Anyway, we are here to see how to count rectangles of a certain size in a grid.

Consider this question: How many 3$$\times$$2 rectangles are there in the 4$$\times$$5 grid below?

I'm a little bit picky here, note that dimensions here are expressed as width$$\times$$height, so in this case I only want 3$$\times$$2 rectangles (that is, a rectangle of width 3 and height 2) and not the 2$$\times$$3 ones.

If we mark an 'X' on every bottom right corner of every 3$$\times$$2 rectangle, we would see this:

Hey, that means counting the number of 3$$\times$$2 rectangles in the original grid is the same as counting how many X's are there, or in other words, it is the same as counting the number of unit squares in an 2$$\times$$4 grid.

There are $$2\times4=8$$ unit squares in a 2$$\times$$4 grid, therefore, the number of 3$$\times$$2 rectangles in the original grid is 8! Hooray!

*munches*

Mmm... so in general, how many $$x\times y$$ rectangles ($$x$$ is the width of the rectangle, $$y$$ is the height of the rectangle) are there in an $$a\times b$$ grid ($$a$$ is the width of the grid, $$b$$ is the height of the grid), given that $$x\leqslant a$$ and $$y\leqslant b$$?

Again imagine marking an 'X' on every bottom right corner of every $$x\times y$$ rectangle, we will get a grid full of X's.

The width of the "X grid" is $$a-x+1$$, while the height of the "X grid" is $$b-y+1$$.

Since the number of $$x\times y$$ rectangles in an $$a\times b$$ grid equals the number of unit squares in the "X grid", hence the number of $$x\times y$$ rectangles in an $$a\times b$$ grid is $(a-x+1)(b-y+1)$

*munches*

The number of $$x\times y$$ ($$x$$ is the width of the rectangle, $$y$$ is the height of the rectangle) rectangles (the exact $$x\times y$$ rectangle, not including rotated variations such as $$y\times x$$) in an $$a\times b$$ grid ($$a$$ is the width of the grid, $$b$$ is the height of the grid) provided that $$x\leqslant a$$, $$y\leqslant b$$ is $(a-x+1)(b-y+1)$

This is one part of Quadrilatorics.

Note by Tan Kenneth
1 year, 3 months ago

Sort by:

I think another way to do it is breaking them up. For example, if we want to count the number ot rectangles in $$10×10$$ grid, is first counting the number of rectangles in $$10×1$$ grid then xounting the number of rectangles in $$10×2$$ grid, then in $$10×3$$, and so in, in this way we would be able to establish a pattern in the number of rectangles, and by arithmetic/geometric progression, we would het the answer. · 1 year, 3 months ago

Yes, but in this case I only want to count rectangles of a specific size. · 1 year, 2 months ago

We can do in that case too. Your questions are awesome. · 1 year, 2 months ago