Cube Counting Puzzles: How to Count Every Cube in a Stack

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

By Riddle10 Editorial Published 11 min read

To solve a cube counting puzzle, turn the drawing into a height grid: look down on the stack, write how tall the tower of cubes on each floor square is, and add the numbers. Hidden cubes become countable once you use the support rule, which says every cube rests on the floor or on another cube, so a top face three cubes high means three cubes in that tower.

Below you will find the support rule, the height grid, three ways to count the same stack, worked through in detail, what front and side views can and cannot tell you, a full worked example and a practice puzzle with its answer.

In this guide, a tower is the pile of cubes standing on one floor square. Rows and columns always mean the lines of squares in the floor grid, never the cubes themselves.

What is a cube counting puzzle?

A cube counting puzzle shows a drawing of identical cubes standing on a floor and asks how many there are. Some cubes sit behind or under others, so you cannot see every one. Other versions ask how many cubes are out of sight, how many more would fill a box, or how many cubes could match a front view and a side view.

The puzzles here follow one plain convention. Every cube rests on the floor or on another cube, so nothing floats. The towers of a stack need not touch each other: a puzzle may show several separate towers standing on the same floor, and you count them all.

Mathematics has a related object with its own name. A solid made of unit cubes joined face to face is called a polycube, and two of them count as the same shape when one is only a shifted copy of the other [1]. A puzzle stack is not required to be one of these, since its towers may stand apart.

Counting every possible polycube of a given size is hard work. A paper accepted on 2 March 2013 studies a special kind called directed polycubes, and it notes that ordinary polycubes, with no restriction, had been counted by size up to 6 cells in 1972 and up to 18 cells by 2006 [1]. The same paper points out that even for flat shapes made of squares, no exact counting formula is known, although many special classes of them have been counted [1].

Your task is much smaller: you only need the number of cubes in one stack, not a list of every shape like it.

Why do hidden cubes matter?

A drawing shows at most three faces of each cube: the top, the front and one side. Any cube that has all three of those faces covered by other cubes is invisible, and in some stacks that can be a good part of the lower layers.

The fix is the support rule. Cubes do not float. If you can see a cube whose top face is three cubes above the floor, there must be two cubes under it, whether you can see them or not.

So never count the cubes you see one by one. Count towers instead. Each tower has a height, and the height is the number of cubes in it.

If a puzzle allows gaps or overhangs, it must say so. Without such a note, assume every tower is solid from the floor up.

What is a height grid, and why does it work?

A height grid is the stack seen from directly above, with a number in each floor square. The number is the height of the tower standing on that square, and an empty square gets a zero. The total number of cubes is simply the sum of the grid.

Many puzzle stacks are pushed into a corner against two walls, so the towers never get taller as you move away from the corner. Mathematicians have a name for exactly this kind of stack.

A paper published on 29 February 2012 defines a plane partition as a grid of whole numbers, none of them negative, that never increase along a row or down a column [2]. Treating each number as a tower of cubes turns the grid into a solid stack tucked into a corner [2].

That paper says such a stack fits in the n-cube when no height is more than n and the grid uses at most n rows and n columns [2]. It also gives a product formula for how many such corner stacks fit inside a cube with n cubes along each edge [2].

The main theorem of that paper compares two of these counts: all corner stacks in the n-cube, and the fully symmetric ones that stay the same under any swap of the three axes [2]. It proves that the first count is divisible by a higher power of 2 than the second when n is even, and by a lower one when n is odd [2]. The trivial box that holds a single cube is the exception, since both counts are the same there.

How do diagonal sums give a third way to count?

A paper accepted on 22 December 2000 looks at the same stacks inside a fixed box [3]. It defines an a by b by c boxed plane partition as an a by b grid of whole numbers from 0 to c that never increase along any row or column [3].

That note reads the numbers as heights. Between two neighbouring squares whose heights differ, it draws one contour line for each step of difference, and the lines never cross one another, though they may share points [3].

Its main object is the diagonal sum: add the heights along each diagonal of the grid, running in the direction of the main diagonal [3]. For a stack picked at random from all those that fit a given box, the note gives a short formula for the average of each diagonal sum, and states that the variance of the total is abc(a + b + c)/12 [3].

You do not need the formulas to use the idea. Every square of the grid lies on exactly one diagonal, so the diagonal sums always add up to the whole stack. That makes diagonals a handy cross-check when you have already counted by rows. The worked example below shows them on a small grid of its own.

Which counting method should you use?

The tower, layer and diagonal methods all count the same cubes, so use two of them and compare the totals. Front and side views only give a smallest and a largest possible count. The table sets them side by side.

MethodWhat you add upBest whenWatch out for
Tower by towerThe height of every tower in the gridYou can see the top of every towerTowers hidden behind taller ones
Layer by layerCubes in each horizontal layerThe stack has a few wide, flat layersMissing a square of a layer behind a taller tower
Diagonal sumsHeights along each diagonal of the gridYou want a quick second checkSkipping the short diagonals at the corners
Box minus gapsThe full box, then subtract the empty spacesThe stack is nearly a complete boxGaps hidden at the back
Front and side viewsOnly the tallest tower in each row and columnThe puzzle gives views, not a drawingViews alone often fit many stacks

What is the step-by-step method?

  1. Draw the floor plan. Sketch a small grid with one square for each floor position the stack covers. Fix which corner is the back corner.
  1. Read the top faces. For every tower whose top you can see, write its height in the grid. Count the height from the floor, not from the cube in front of it.
  1. Fill hidden towers with the support rule. A hidden top face still sits on a solid tower down to the floor. In a stack pushed into the back left corner, a hidden tower is also at least as tall as the towers in front of it and to its right.
  1. Add the grid. Add each row, then add the row totals.
  1. Check with layers. Count how many squares have height at least one, at least two, and so on. These layer counts must give the same total.
  1. Answer the question asked. Some puzzles want the cubes out of sight, or the cubes still needed to fill a box, rather than the total.

How do you count a stack in a worked example?

Picture a stack pushed into the back left corner of a box three squares deep, four squares wide and three cubes tall. From the front you see a staircase that climbs towards the back wall and towards the left wall. Reading the top faces gives this height grid, with row 1 against the back wall and column 1 against the left wall.

Col 1Col 2Col 3Col 4
Row 13321
Row 23210
Row 32110

Step 1: check the shape. The numbers never rise along a row from left to right or down a column from back to front. So the stack is a true corner stack.

Step 2: count by towers. The towers in the back row hold nine cubes, the middle row six and the front row four, so the stack has nineteen cubes in all.

Step 3: count by layers. Ten squares have at least one cube, six have at least two and three have at least three. Ten plus six plus three is again nineteen.

Step 4: count by diagonals. Each diagonal runs parallel to the line from the back left square to the front right square. Start with the diagonal through the front left square and move towards the back right corner. The diagonal sums are two, four, six, four, two and one, which also add up to nineteen.

Step 5: answer the side questions. Looking straight down, you see one top face for each of the ten covered squares, so nine cubes are out of sight from above. The full box would hold thirty-six cubes, so seventeen more would fill it.

When three methods agree, you can trust the count. If two methods disagree, read each tower's height again, counting from the floor up.

What can front and side views tell you?

Some puzzles skip the drawing and give two flat views instead. The same convention holds: every cube rests on the floor or on another cube, and the towers need not touch each other. The front view gives, for each column of the floor grid from left to right, the height of the tallest tower in that column. The side view gives, for each row from back to front, the height of the tallest tower in that row.

For the worked example, the front view reads 3, 3, 2, 1 and the side view reads 3, 3, 2. Those two views do not fix the count. If you list every height grid on the same floor that matches both views, the smallest stack has nine cubes and the largest has twenty-five.

Two quick rules give these limits without listing every case. Both views always share the same largest number, the height of the tallest tower. The least-count rule relies on the convention that towers may stand apart:

  • Greatest count. In each square, put the smaller of two heights: the side-view height of its row and the front-view height of its column. Then add the grid.
  • Least count. Add all the numbers in both views. Then pair up equal numbers, one from the front view with one from the side view, using each number at most once. For every pair, subtract its value once, because a single tower standing where that row meets that column shows up in both views at once.

For the worked example, the two views add up to seventeen. The front view has 3, 3, 2 and the side view has 3, 3, 2, so three pairs form and remove eight, which leaves nine.

Which mistakes should you watch for?

  • Counting only visible cubes. The cubes under and behind others are part of the stack.
  • Reading heights from the wrong level. A cube that looks tall may be standing on a lower step at the front.
  • Forgetting empty squares. A zero in the grid is real, and it changes the layer counts.
  • Assuming gaps. Unless the puzzle says so, every tower is solid down to the floor.
  • Answering the wrong question. Check whether the puzzle asks for the total, the hidden cubes or the cubes still missing.

Can you solve this practice puzzle?

A stack stands on a floor three squares wide and three squares deep. Every cube rests on the floor or on another cube, and the towers need not touch each other. The front view, from left to right, reads 3, 2, 2. The side view, from back to front, reads 3, 2, 1. What is the least number of cubes the stack can have, and what is the greatest?

A hint: start with the tallest towers, since a single tower of three can explain the 3 in both views.

Answer: at least eight cubes and at most sixteen. Here is one stack with eight cubes, made of four separate towers.

Col 1Col 2Col 3
Row 1302
Row 2020
Row 3100

The largest stack is the only one with sixteen cubes. Each square takes the smaller of its row's height in the side view and its column's height in the front view.

Col 1Col 2Col 3
Row 1322
Row 2222
Row 3111

Both limits can be checked by listing every height grid that fits the two views. Check the least stack yourself with the rule: the views add up to thirteen, and pairing the 3 with the 3 and one 2 with a 2 removes five.

Ready to put the height grid to work on a real drawing? This riddle shows a stack of cubes and asks how many cubes are in it.

References

  1. Champarnaud, J.-M., Dubernard, J.-P., & Jeanne, H. (2013, March 29). A generic method for the enumeration of various classes of directed polycubes. Discrete Mathematics & Theoretical Computer Science, 15(1), 183-200. DOI 10.46298/dmtcs.637
  2. Keith, W. J. (2012, February 29). The 2-adic Valuation of Plane Partitions and Totally Symmetric Plane Partitions. The Electronic Journal of Combinatorics, 19(1), P48. DOI 10.37236/2064
  3. Wilson, D. B. (2000, December 22). Diagonal Sums of Boxed Plane Partitions. The Electronic Journal of Combinatorics, 8(1), N1. DOI 10.37236/1586

cube counting puzzles spatial puzzles visual puzzles height grid step by step solving methods

More reading