Checkerboard Squares Problem

How Many Squares On A Checkerboard

PL
edydiplom.com
7 min read
How Many Squares On A Checkerboard
How Many Squares On A Checkerboard

You're at a bar. Someone slides a napkin across the table, draws an 8×8 grid, and asks the question that's ruined more friendly arguments than politics: how many squares on a checkerboard?

You say sixty-four. They grin. You're wrong.

The real answer is two hundred four. And if you're already scrolling to the comments to tell me I can't count, stay with me — this is one of those problems that looks trivial until you actually sit down with it.

What Is the Checkerboard Squares Problem

At its core, this is a counting problem disguised as a geometry puzzle. Still, a standard checkerboard — or chessboard, same thing — gives you an 8×8 grid of alternating light and dark squares. Most people count the individual unit squares, get sixty-four, and call it a day.

But the question asks for squares*. Still, plural. In real terms, all of them. Not just the 1×1 squares. The 2×2 squares. The 3×3 squares. All the way up to the single 8×8 square that forms the whole board.

The breakdown nobody expects

Here's where it gets interesting. On an 8×8 board:

  • 1×1 squares: 64 (8 across × 8 down)
  • 2×2 squares: 49 (7 across × 7 down)
  • 3×3 squares: 36 (6 across × 6 down)
  • 4×4 squares: 25 (5 across × 5 down)
  • 5×5 squares: 16 (4 across × 4 down)
  • 6×6 squares: 9 (3 across × 3 down)
  • 7×7 squares: 4 (2 across × 2 down)
  • 8×8 squares: 1 (the whole board)

Add them up: 64 + 49 + 36 + 25 + 16 + 9 + 4 + 1 = 204.

The pattern should jump out at you. Those are perfect squares in reverse: 8² + 7² + 6² + 5² + 4² + 3² + 2² + 1².

Why It Matters / Why People Care

This isn't just a party trick. The checkerboard problem shows up in combinatorics, computer science, and technical interviews for a reason — it tests whether you can recognize a pattern and generalize it, not just count on your fingers.

The interview trap

I've watched strong candidates freeze on this. The formula exists — it's n(n+1)(2n+1)/6 for an n×n board — but unless you're applying for a math-heavy role, nobody expects you to pull it from memory. Even so, they'll write out the summation correctly, then panic and try to derive a closed-form formula on a whiteboard while the interviewer watches. What they do expect is that you can explain why the sum of squares works, and maybe write a quick loop to verify it.

Real-world analogs

This same counting logic appears in image processing (sliding window detectors), game development (collision detection on grids), and even spreadsheet algorithms. Anytime you're scanning a 2D array for sub-patterns of varying sizes, you're solving a version of this problem.

How It Works

Let's walk through the reasoning slowly enough that you could explain it to a ten-year-old — or a hiring manager who's never seen the problem before.

Step 1: Define what you're counting

A "square" on the board means any set of unit squares that forms a perfect square shape. Orientation matters — we're only counting axis-aligned squares, not rotated ones. (Rotated squares are a whole different rabbit hole involving Pythagorean triples. Let's not go there today.

Step 2: Count positions for each size

For a k×k square on an n×n board, how many positions can its top-left corner occupy?

Horizontally: the left edge can start at column 1, 2, ...Practically speaking, vertically: same logic, n−k+1 positions. Think about it: that's n−k+1 positions. That said, , up to n−k+1. Total positions for that size: (n−k+1)².

On an 8×8 board with k=3: (8−3+1)² = 6² = 36. Matches our table above.

Step 3: Sum across all possible sizes

k ranges from 1 to n. So the total is Σ(k=1 to n) (n−k+1)².

For more on this topic, read our article on flag one star red white and blue or check out what was the western front in ww1.

Re-index with j = n−k+1. As k goes 1→n, j goes n→1. The sum becomes Σ(j=1 to n) j².

That's the sum of the first n perfect squares.

Step 4: Apply the formula (or don't)

The closed form: n(n+1)(2n+1)/6.

For n=8: 8×9×17/6 = 1224/6 = 204. Checks out.

But honestly? In an interview, I'd rather see you write a three-line Python snippet than recite that formula. Now, shows you can code. Worth adding: shows you verify. Shows you're practical.

def count_squares(n):
    return sum((n - k + 1) ** 2 for k in range(1, n + 1))

print(count_squares(8))  # 204

Generalizing to rectangles

Here's a twist that catches people: how many rectangles* (including squares) on an 8×8 board?

Different problem. Choose 2 vertical lines from the 9 grid lines, and 2 horizontal lines from the 9 grid lines. But c(9,2) × C(9,2) = 36 × 36 = 1,296 rectangles total. Squares are just a subset.

Common Mistakes / What Most People Get Wrong

Mistake 1: Stopping at 64

The obvious one. Here's the thing — you counted the unit squares and quit. Day to day, the problem says "squares," not "smallest squares. " Language matters.

Mistake 2: Double-counting overlapping squares

Some people think a 2×2 square "contains" four 1×1 squares and try to subtract them out. Don't. Each square is a distinct object defined by its position and size. Practically speaking, the 2×2 square at rows 1-2, columns 1-2 is a different square than the 1×1 at row 1, column 1. They overlap spatially but they're distinct combinatorial objects.

Mistake 3: Forgetting the board itself

The 8×8 square is a square. I've seen people sum 1² through 7² and get 140, then stare at the board wondering where the other 64 went. And it counts. The board is the largest square. It's easy to miss because it doesn't feel like a "square on the board" — it is the board. And that's really what it comes down to.

Mistake 4: Confusing squares with rectangles

As noted above, 1,296 rectangles vs 204 squares. Also, if it asks for rectangles, don't give the square count. If the question asks for squares, don't give the rectangle count. Read the prompt.

Mistake

Mistake 5: Misapplying the "n-squared" logic to non-square boards

What if the board isn't a square? Suppose you have a $3 \times 5$ rectangular board. A common error is to try and use the $n(n+1)(2n+1)/6$ formula by simply averaging the dimensions or picking the larger one.

That won't work. For a $m \times n$ board, the number of $k \times k$ squares is limited by the shorter* dimension. On the flip side, the number of positions for a $k \times k$ square is $(m-k+1) \times (n-k+1)$. You must sum this product for all $k$ from 1 to $\min(m, n)$.

If you jump straight to a single-variable formula without checking if $m = n$, you'll fail the edge case.

Summary and Takeaways

Combinatorics problems like "counting shapes on a grid" are staples in technical interviews and math competitions because they test three distinct skills:

  1. Pattern Recognition: Can you see that the number of positions follows a sequence of decreasing squares?
  2. Mathematical Rigor: Do you know how to formalize that pattern into a summation or a closed-form formula?
  3. Attention to Detail: Do you realize that the $8 \times 8$ board itself is a valid square, or do you stop at the $1 \times 1$ units?

When faced with these problems, don't rush to a number. On the flip side, start by drawing a small $3 \times 3$ grid, manually counting the squares to find the pattern, and then generalizing. Whether you use the sum of squares formula or a quick Python loop, the goal is to demonstrate a logical path from a visual problem to a concrete solution.

Next time you see a grid, don't just see lines and boxes—see the underlying sequences.

New

Latest Posts

Related

Related Posts

Thank you for reading about How Many Squares On A Checkerboard. We hope this guide was helpful.

Share This Article

X Facebook WhatsApp
← Back to Home
ED

edydiplom

Staff writer at edydiplom.com. We publish practical guides and insights to help you stay informed and make better decisions.