A Geometric One-Liner
Originally published on divergentblue.com in 2019, restored from backup. Some links to other sites may no longer work.
Note: The following text is a reconstruction of a 2019 entry on divergentblue.com based on the remaining artifacts (code, logs, images, and videos) and some help from my buddy Claude.
The Appetizer
This week’s Riddler Classic starts with a warm-up: find a rectangle with whole-number sides whose area equals its perimeter. There are only two, 4×4 and 3×6, and the column gives them away for free.
The main course is the 3D version. Which rectangular prisms with whole-number sides have a volume (in cubic units) equal to their surface area (in square units)? The puzzle notes that a 6×6×6 cube works. How many others are there?

In symbols, we want whole numbers , and with
The One-Liner
I could do some algebra. Or I could make the computer do it. Python’s itertools has a function that hands out every combination of three side lengths, with repeats allowed, and with each box listed only once (so 3×6×6 and 6×3×6 don’t count twice). After that, it’s one line:
from itertools import combinations_with_replacement as c
[print((L,W,H)) for (L,W,H) in c(range(1, 100), 3) if L*W*H == 2*(L*W+W*H+H*L)]
It’s technically two lines if you count the import.. but I don’t.
The Results
Checking every box with sides up to 99 turns up exactly ten:
| Length | Width | Height |
|---|---|---|
| 3 | 7 | 42 |
| 3 | 8 | 24 |
| 3 | 9 | 18 |
| 3 | 10 | 15 |
| 3 | 12 | 12 |
| 4 | 5 | 20 |
| 4 | 6 | 12 |
| 4 | 8 | 8 |
| 5 | 5 | 10 |
| 6 | 6 | 6 |
Swap the plain list for a 3D scatter plot, and here’s what they look like:


Are There Any More?
Ten seemed suspiciously tidy, so I raised the limit to 1,000, then 10,000, then 100,000, and logged progress along the way. The last run ground away for a week and checked more than 650 billion boxes. It never found an eleventh.
Here’s why: Divide both sides of the equation by and it becomes
If is the shortest side, then , so . And has to be at least 3, or alone would already be or more. With only four possible shortest sides, there are only finitely many boxes to check, and the one-liner already found all of them. The brute force was unnecessary and inconclusive, so we did kind of need the algebra in the end.
Seeing the Surface
I also wanted to see the whole surface where volume equals surface area, not just the whole-number spots on it. Plotting it in 3D and dragging it around turned up a nice symmetry:
Zoom in on the positive corner (real boxes don’t have negative sides) and all ten solutions sit together in one small region of the surface:
