# Cubes touching all other cubes

This question is based on this great puzzle: Puzzle about 6 infinite cylinders in space

What is the most number of identical cubes that can be placed, such that every cube touches all the other cubes at some location? Cubes cannot overlap.

I propose two versions of this puzzle, thanks to @JaapScherphuis:

1. Two cubes are considered touching if they touch anywhere, including at a corner, edge or face.
2. Two cubes are considered touching if they touch at a face.

Part 1:

8 cubes. In a 2x2x2 arrangement all cubes touch each other at the centre.

Part 2:

6 cubes. Pack 3 cubes together in a layer so they are mutually touching. Two such layers can be stacked so that each cube touches all those in the other layer as shown in this picture.

Here is a slightly handwavey argument for optimality.

Two touching cubes can either be aligned (every pair of opposite faces is parallel to a pair of opposite faces on the other cube) or not aligned (only the touching faces and their opposites are parallel, and all other pairs of opposite faces are not parallel to any faces of the other cube). So touching cubes are either aligned along all three axes or else share exactly one axis.
Consider two touching cubes A and B that are not aligned, i.e. they have only one axis in common which I'll call the main axis. Now try to add another cube that touches both. It cannot touch both cubes only on their parallel planes, so must touch one of them, say A, on some other face. For it to also touch cube B, it will have to align along the main axis, and touch the same face of B that A is touching.
The same argument holds for any further cubes we add, so what happens is that we have two blocks of fully aligned cubes, the blocks touching each other in one plane. Each block is obviously only one layer thick, but must also consist of mutually touching cubes. This turns it into a 2-dimensional problem, the maximum number of mutually touching squares in the plane. It is fairly easy to convince yourself that 3 is the maximum.
So the best we could do is to take two layers of 3 mutually touching cubes, and put them together such that they all touch each other, as in the solution above.

• Nice solutions! I am convinced that part 1 is optimal. Can we prove that part 2 is optimal? Commented Apr 2, 2021 at 4:02
• @DmitryKamenetsky I've added an argument for it being optimal. Commented Apr 2, 2021 at 7:28
• How does Part 2 get round "Cubes cannot overlap"? Commented Apr 5, 2021 at 20:15
• They aren't overlapping, merely on top of each other. It's just not presented in a 2D fashion so it's harder to realise. Commented Apr 5, 2021 at 20:49

Questions does not specify

that the cubes must be non-overlapping

Therefore, it is possible to

use an arbitrarily large number of overlapping cubes, all sharing at least one point on a common face.

As such the answer to part 1 is

"unlimited" or "infinite", depending on your preferred terminology.

and the answer to part 2 is

the same, as the cubes can already be arranged to share a face.

• good catch, but they should be non overlapping Commented Apr 1, 2021 at 10:09