How Many Squares Puzzle: Count Squares, Rectangles and Triangles

This article was written with AI and may contain mistakes. Found one? Tell us.

By Riddle10 Editorial Published 10 min read

To solve a how many squares puzzle, count the shapes one size at a time instead of searching for them by eye. In a 4 by 4 grid there are 16 small squares, 9 of size two, 4 of size three and 1 of size four, so the answer is 30, and the same size-by-size habit cracks rectangle and triangle puzzles too.

This guide gives the method in six steps, a table of quick formulas, a full worked example, a triangle example and a practice grid with its answer. Every count here can be checked by listing every case, one shape at a time.

Why do people get counting puzzles wrong?

A counting puzzle looks easy because every shape is in plain sight. The trouble is that shapes overlap. A large square is made of smaller squares, and the eye locks on to the small ones and stops there.

Watch for three habits. Counting only the smallest pieces, counting some shapes twice from two directions, and forgetting the outline of the whole figure, which is often the biggest shape of all.

The fix is a fixed order. Decide on a size, count every shape of that size, write the number down, then move to the next size. A written list of sizes also lets you go back and check each line on its own.

What is the size-by-size method?

  1. Name the shape. Read the question closely. Squares only, or all rectangles? Triangles pointing up only, or any triangle at all? Upright shapes only, or tilted ones too?
  1. List the sizes. Write down every size the shape can take, from the smallest piece to the whole figure.
  1. Count one size at a time. For each size, slide a frame of that size across the figure and count the places it fits. Move left to right, then down a row.
  1. Write each count down. Keep a small table with one row per size. This stops double counting.
  1. Look for a pattern. In regular grids the counts per size follow a simple rule, such as square numbers. A pattern is a quick check on your arithmetic.
  1. Add and check. Total the table, then check one size again by a different route, for example by counting corners.

How many squares are in a 4 by 4 grid?

Picture a 4 by 4 grid of small squares, like a quarter of a chessboard. Each small square has sides of length one. Here is the full count, one size at a time.

Size one. There are 4 small squares in each row and 4 rows, so 16 in all.

Size two. A 2 by 2 frame can sit in 3 positions across a row, because it needs two columns and there are only 4. It can also sit in 3 positions down. That makes 3 times 3, or 9.

Size three. A 3 by 3 frame fits in 2 positions across and 2 down, so 4.

Size four. The whole outline is one square, so 1.

Square sizePositions acrossPositions downCount
1 by 14416
2 by 2339
3 by 3224
4 by 4111
Total30

Notice the counts: 16, 9, 4 and 1 are the square numbers in reverse. For any square grid with n small squares on a side, the total is 1 squared plus 2 squared and so on up to n squared. Try it on a full chessboard, and check one size at a time against your own list.

Is there a neat fact hiding in that sum of squares?

There is, and it ties this grid puzzle to an equation about square numbers: 1 squared plus 2 squared and so on, up to some number squared, equals another number squared.

A paper published on 25 September 2018 notes that, apart from 1 by itself, the squares of the whole numbers from 1 to 24 are the only run of squares starting at 1 whose sum is itself a square, namely 70 squared [1].

This link is our own. A run of squares starting at 1 is exactly the count of squares of all sizes in a square grid. Adding the squares of the numbers 1 to 24 (1 squared, 2 squared and so on up to 24 squared) gives 4,900, which is 70 squared [1], so a 24 by 24 grid holds a perfect-square number of squares.

The paper states that this sum-of-squares equation has no other solution [1], so apart from the 1 by 1 grid and the 24 by 24 grid, no square grid holds a perfect-square number of squares.

How do you count rectangles in a grid?

Rectangles include squares, and there are many more of them. The trick is to stop thinking about cells and start thinking about lines.

Every rectangle in a grid is fixed by two of the horizontal lines and two of the vertical lines. A 4 by 4 grid has 5 horizontal lines and 5 vertical lines. You can pick two of the 5 horizontal lines in 10 ways, and two vertical lines in 10 ways, so there are 10 times 10, or 100 rectangles.

The same idea gives squares in a grid that is not square. Count each size as before, but the number of positions across and down now differs. In a grid of 2 rows and 3 columns there are 6 small squares and 2 squares of size two, and no larger ones.

Here is a quick comparison of the main shape-counting rules.

FigureWhat you countQuick rule
Square grid, n by nUpright squares1 squared plus 2 squared up to n squared
Rectangular gridUpright squaresFor each size, positions across times positions down
Any grid of linesRectangles, squares includedPairs of horizontal lines times pairs of vertical lines
Triangle with lines from the top cornerTrianglesPairs of lines from the corner, times the number of cross lines counting the base as one
Triangle cut into small trianglesTrianglesCount pointing up and pointing down separately, size by size
Square array of dotsSquares with dot cornersUpright squares plus tilted squares

What about tilted squares on a grid of dots?

Dot puzzles ask how many squares you can make by joining four dots. Here the upright squares are only part of the answer, because a square can lean.

Take a 4 by 4 array of dots, which outlines a 3 by 3 grid of cells. The upright squares number 9, 4 and 1, so 14. Now look for tilted squares. A square whose corners sit on the midpoints of the sides of a 2 by 2 block of cells is tilted and fits in 4 places. A larger tilted square fits inside the full 3 by 3 block, and it can lean either way, which gives 2 more.

That gives 6 tilted squares and 20 squares in all. You can confirm it by testing every set of four dots.

The habit to build: for each tilted square, look at the smallest upright box around it. Each upright box of a given size holds a fixed number of tilted squares, so you can count boxes instead of squares.

How do you count triangles in a figure?

Triangle puzzles come in two common forms, and each has its own approach.

Lines from one corner. Draw a triangle and add lines from the top corner down to the base, cutting the base into pieces. Every triangle in the figure uses the top corner and two of the lines that leave it. If the base is cut into 4 pieces, there are 5 lines from the top corner, and two of them can be chosen in 10 ways, so the figure holds 10 triangles.

Add one straight cross line parallel to the base, and each pair of corner lines now makes two triangles, one cut off by the cross line and one by the base. The count doubles to 20. You can confirm both totals by listing every set of three lines that meet in pairs.

A triangle cut into small triangles. Now take a large triangle with each side split into 3 equal parts and lines drawn parallel to all three sides. This makes a grid of small triangles. Count the ones pointing up and the ones pointing down separately, size by size.

SizePointing upPointing down
Side one63
Side two30
Side three10
Total103

That gives 13 triangles. The downward ones are easy to miss, and a large downward triangle needs a lot of room, so it only appears once the big triangle is split into at least 4 parts per side. A triangle split into 4 parts per side holds 27 triangles.

How many cells of each colour does a grid have?

Sometimes you want not just how many cells there are but how many of each colour. On a chessboard the two colours split evenly. On an odd grid it is less obvious.

A paper published on 20 March 2025 looked at grids coloured so that colours repeat in a fixed cycle along every row and every column [2]. It gives the example of a 9 by 13 checkerboard, which has 59 squares of one colour and 58 of the other [2].

With two or more colours, and both sides at least as long as the number of colours, the paper shows a simple rule: if the number of colours divides the length of at least one side, every colour appears equally often, the number of cells divided by the number of colours [2]. When neither side divides evenly, the counts differ slightly. For a 13 by 19 grid with 5 colours, the counts are 49, 49, 50, 50 and 49 [2].

The paper compares two ways to get such counts [2]. A brute-force count visits every cell, while its closed formula needs only a fixed number of steps however large the grid is [2]. It also checked the formula against brute-force counts for many grid sizes [2].

Both colour examples can be checked by colouring every cell and tallying. This is the same lesson as the squares table above. Counting one by one always works, but a pattern turns a long count into a short sum.

Which counting mistakes should you watch for?

  • Forgetting the outline. The whole figure is usually a shape of the kind you are counting.
  • Mixing squares and rectangles. Read the question twice. A rectangle question includes the squares.
  • Missing shapes that lean or point down. Tilted squares on dot grids and downward triangles on triangle grids are easy to skip, so give them their own line in your list.
  • Counting the same shape twice. If you jump around the figure, you lose track. Sweep left to right, then down.
  • Counting a shape whose side is not drawn. A shape only counts if every side lies along a line in the figure.

How can you check your answer?

  • Count one size again with a different method, such as counting top-left corners instead of whole shapes.
  • Try a smaller version of the same figure, count it by hand, and see whether your rule gives the same answer.
  • For rectangles, use the line-pair rule as a cross-check against a size-by-size count.
  • Look for a pattern in your table. Counts per size in a regular figure usually follow a smooth rule, and a number that breaks the pattern is often a slip.

Can you solve this practice puzzle?

Picture a grid of 3 rows and 4 columns of small squares. Answer two questions. How many squares of every size does it contain? How many rectangles, squares included?

A hint: for the squares, the biggest possible size is 3 by 3. For the rectangles, count the horizontal and vertical lines first.

Answer: there are 20 squares and 60 rectangles.

Square sizePositions acrossPositions downCount
1 by 14312
2 by 2326
3 by 3212
Total20

For the rectangles, the grid has 4 horizontal lines and 5 vertical lines. Two horizontal lines can be picked in 6 ways and two vertical lines in 10 ways, so there are 60 rectangles. Take away the 20 squares and 40 of them are rectangles that are not squares.

Where can you practise next?

Ready to try one yourself? This riddle asks a single question: how many triangles are in the figure? Work through it size by size and write each count down.

This one shows twelve glowing dots and asks how many squares you can make by joining four of them.

References

  1. Laverty, B., & Murphy, T. (2018, September 25). Optimal Rectangle Packing for the 70 Square. Recreational Mathematics Magazine, 5(9), 5-47. DOI 10.2478/rmm-2018-0001
  2. Garvie, M. R. (2025, March 20). Counting the Number of Squares of Each Colour in Cyclically Coloured Rectangular Grids. Mathematics, 13(6), 1013. DOI 10.3390/math13061013

counting shapes how many squares counting triangles visual puzzles grid puzzles step by step

More reading