The concept
Start with something familiar
How many squares are on a chessboard? Most people say 64 and stop. But the whole board is a square too, and so is every 2 by 2 block, every 3 by 3 block, and so on. The true answer is 204.Counting questions in GATE work exactly like this. The figure is simple, but the small shapes hide inside bigger ones, and you lose marks by missing some or counting some twice. The cure is never to count by eye. Count by size, or by choosing lines, so that every shape is counted exactly once.Idea 1: in an n by n grid, a k by k square fits in (n − k + 1)² places
Take a 3 by 3 grid of small squares. Where can a 2 by 2 square sit? Its top-left corner can be in the first or second column (2 choices) and in the first or second row (2 choices). That's places. In general, a by square can slide into positions across and the same number down.| Size | Across | Down | Count |
|---|---|---|---|
| 1 by 1 | 3 | 3 | 9 |
| 2 by 2 | 2 | 2 | 4 |
| 3 by 3 | 1 | 1 | 1 |
| Total | 14 |
Play with it
Each dot is a place for the 2 by 2 square's top-left corner: 2 × 2 = 4. All sizes: 9 + 4 + 1 = 14.
Adding over every size gives the sum of the first squares:
Example
How many squares are on an 8 by 8 chessboard?
.
.
Idea 2: in a rectangular grid, choose two lines each way
Now take a grid that is squares tall and squares wide. Squares still slide, but the counts across and down differ:Here can be at most the shorter side.For rectangles (which include squares), there's a neater trick. Every rectangle is fixed by choosing 2 of the horizontal grid lines (its top and bottom) and 2 of the vertical grid lines (its two sides). A grid tall has horizontal lines, and one wide has vertical lines:Example
Count the squares and the rectangles in a grid 2 squares tall and 3 wide.
Squares: of size 1 and of size 2, so 8. Rectangles: there are 3 horizontal and 4 vertical lines, so .
Squares: of size 1 and of size 2, so 8. Rectangles: there are 3 horizontal and 4 vertical lines, so .
Idea 3: lines from one corner make triangles in pairs
Draw a triangle, then draw some straight lines from its top corner down to the base. Every small triangle you can see has the top corner as one vertex, and its two slanted sides are two of the lines from the top (the two original sides count as lines too). The base supplies the third side.So if there are lines from the top corner in total, each pair of them makes one triangle:If the figure also has lines running across from one side to the other, parallel to the base, each such line (and the base itself) is a new base that works the same way. With bases:| Lines | Bases | Triangles |
|---|---|---|
| 3 | 1 | |
| 4 | 1 | |
| 4 | 2 | |
| 6 | 3 |
Example
A triangle has two extra lines from its top corner to the base. How many triangles are there?
Lines from the top: 2 sides plus 2 extra, so . Triangles .
Lines from the top: 2 sides plus 2 extra, so . Triangles .
Idea 4: when there's no formula, label the pieces and count by how many pieces join
For an irregular figure, give every smallest region a number. Then list triangles made of 1 piece, then 2 pieces, then 3, and so on. Writing the list stops you from counting the same triangle twice.Take a square with both diagonals drawn. The diagonals cut it into 4 small triangles; label them 1 (bottom), 2 (right), 3 (top), 4 (left).| Pieces joined | Triangles | Count |
|---|---|---|
| 1 | 1, 2, 3, 4 | 4 |
| 2 | 1+2, 2+3, 3+4, 4+1 | 4 |
| 3 | none | 0 |
| Total | 8 |
Example
Why is 1+2+3 not a triangle?
Three of the four pieces form the square with one quarter missing, a shape with five sides. Joining pieces only gives a triangle if the outline has exactly three straight sides.
Three of the four pieces form the square with one quarter missing, a shape with five sides. Joining pieces only gives a triangle if the outline has exactly three straight sides.
Idea 5: in a triangular grid, count the upright and upside-down triangles separately
Divide each side of a big triangle into equal parts and draw lines parallel to the sides. You get a grid of small triangles, some pointing up and some pointing down. Upright triangles come in every size from 1 to . Upside-down ones only fit up to about half the size, because they need room above and below.For :| Size | Upright | Upside-down |
|---|---|---|
| 1 | 6 | 3 |
| 2 | 3 | 0 |
| 3 | 1 | 0 |
| Total | 10 | 3 |
Example
How many triangles are in a triangular grid with 4 parts on each side?
Upright: . Upside-down: 6 of size 1 and 1 of size 2, so 7. Total .
Upright: . Upside-down: 6 of size 1 and 1 of size 2, so 7. Total .
How to spot which idea you need
| The question says... | Use |
|---|---|
| squares in a square grid | Idea 1: |
| a rectangular grid, or "rectangles" | Idea 2: choose 2 lines each way |
| lines fanning out from one corner | Idea 3: |
| an irregular figure | Idea 4: label pieces, count by size |
| a triangle cut into small triangles | Idea 5: upright plus upside-down |
Worked example 1warm-up
How many squares and how many rectangles are there in a 5 by 5 grid?Solution
Step 1. Squares by sizeIdea 1
.
Step 2. Rectangles by choosing linesIdea 2
A 5 by 5 grid has 6 lines each way: .
Step 3. Check
The formula gives squares, matching Step 1. And 225 is more than 55, as it must be, since every square is also a rectangle.
Worked example 2GATE level
A square has both diagonals drawn, and also the two lines joining the midpoints of opposite sides (one across, one down). How many triangles does the figure contain?Solution
Step 1. Find the smallest piecesIdea 4
The four lines all pass through the centre and cut the square into 8 thin triangles. Number them 1 to 8 going round the centre, starting with the left half of the bottom edge.
Step 2. Two pieces
Pieces 1 and 2 meet along the line from the centre down to the middle of the bottom edge, and together they form the triangle with corners at the centre and the two bottom corners of the square. The same happens on each side: 1+2, 3+4, 5+6, 7+8. That's 4. Pairs such as 2+3 form a small square, not a triangle.
Step 3. Three pieces
Any three neighbouring pieces have a bent outline with four or more sides, so 0.
Step 4. Four pieces
Half of the big square, cut along a diagonal: 1+2+3+4, 3+4+5+6, 5+6+7+8 and 7+8+1+2. That's 4.
Step 5. Total
triangles.
Step 6. Check
Each diagonal splits the square into 2 halves, giving big triangles, which matches Step 4. And Idea 4's square with only the diagonals had 8 triangles (4 quarters and 4 halves). All 8 are still here, and the middle lines add the 8 thin pieces, giving 16.
All the equations at a glance
| Idea | Equation |
|---|---|
| Squares, grid | |
| Squares, grid | |
| Rectangles | |
| Fan from a corner | |
| Irregular figure | label pieces, count by size |
| Triangular grid | upright plus upside-down |