I was asked this question in a job interview recently: “How many basketballs will fit in this room?” As it turns out, this is quite a common interview question, designed to gauge a candidate’s problem solving skills and ability to think on their feet and handle unexpected challenges. It also turns out that a lot of mathematicians have thought about problems like this, and in fact developed an entire field based around generalisations of this question, which they call ‘sphere packing’. We’ll explore the field of sphere packing and use it to solve the problem in the interview question.

Sphere packing problems, essentially, ask “What is the maximum density, by volume, that can be achieved, when filling a space with spheres?” Usually, such problems consider a space without boundaries (an infinite space). If we were to consider finite space, then our maximum density would depend on the size of the space relative to the size of the spheres. Consider a rectangular prism, ever so slightly too small to accommodate another row of spheres at one edge. If we extend the space a tiny bit in that direction, we can fit a much larger number of spheres into it. Thus, the complications that occur at the boundaries of finite spaces are avoided by instead considering infinite spaces, to facilitate the development of more general solutions.

Sphere packing problems are not limited to three dimensional spaces. The question of optimal density for circles on a 2D plane would also be considered a sphere packing problem, as would the question of how to optimally pack hyper-spheres in four or more spatial dimensions. Although much of sphere packing concerns spheres of uniform size, mathematicians have also considered filling space with spheres of two or perhaps three unique sizes. The answers to these non-uniform problems are useful in chemistry, for understanding the density of crystals, which are essentially regular patterns (lattices) of one or more elements, each element being an atom (a roughly spherical object) with a distinct radius.

Today, however, we are concerned with how many basketballs we can fit in a room. Essentially, we are packing uniform spheres into a three dimensional space. I won’t go through the proof, but mathematicians have found that the maximum possible density for such an arrangement is \(\frac{\pi}{3\sqrt{2}} \approx 0.74\). Alternatively, no matter how tightly we pack the spheres, we will always have at least \(26%\) empty space, regardless of the size of the spheres. This optimal density can be achieved by packing the spheres into layers consisting of staggered rows, and then packing these layers on top of each other, again in a staggered arrangement. This density value will prove useful in determining how many basketballs we can fit into our room.

Let’s say our room is rectangular, having dimensions \(3m\) by \(4m\), and being \(2.4m\) tall floor to ceiling. This gives our room a volume of \(28.8m^3\). A men’s official competition basketball has a circumference of \(0.76m\) when properly inflated. Working backwards, such a basketball has a radius of \(0.12m\), and therefore a volume of \(7.4\times 10^{-3}m^3\). Logically, we would divide the volume of the room by the volume of a basketball,finding that 3885 basketballs would fit in our room. However, this neglects the fact that we cannot pack spheres into a three dimensional space without at least \(26%\) empty space between them, as mathematicians have so kindly informed us. To account for this, we multiply the number of spheres we can fit in our room by the aforementioned sphere packing density, \(\frac{\pi}{3\sqrt{2}} \approx 0.74\). Now we see that (assuming the basketballs are as tightly packed as possible, and ignoring the boundary conditions), we can fit at most 2878 basketballs in our room. Of course, since we know that the boundary conditions will always lead to the actual number of basketballs in the room being less than or equal to this value, we can call it an upper bound. Thus we say that we can fit no more than 2878 basketballs in our room.

So next time you’re heading to a job interview and want to impress your interviewers, you may consider bringing a tape measure and the following formula:

\(Basketballs = \frac{length\times width\times height\times \frac{\pi}{3\sqrt{2}}}{7.4\times 10^{-3}}\)