You may find the
Sphere Cube problem to be similar.
Four identical spheres (like the ones shown in blue in the above cube case) are arranged in a pyramid, such that each sphere is tangent to the other three. If the radius of the four spheres is R, what is the radius r of the largest sphere (such as the one shown in red on the cube picture) that could exist inside the pyramid without overlapping the other spheres?
The centers of the four spheres form the vertices of a regular tetrahedron of side length 2R, so we may place them on the vertices (x,x,x), (x,-x,-x), (-x,x,-x), and (-x,-x,x) of the cube of side length 2x where x = R*sqrt(2)/2.
The desired radius is then the distance from the center (0,0,0) of the cube to a vertex, minus R. So we have
r = x*sqrt(3)-R
= R(sqrt(6)/2 - 1).