Three spheres of radius $r$ lie on the lower base of a regular triangular prism, each touching two other spheres and two lateral faces of the prism. On these spheres lies a fourth sphere, which touches all the lateral faces and the upper base of the prism. Find the height of the prism.
Let $O_1$, $O_2$, $O_3$ be the centers of the spheres touching the bottom base of the prism, $O$ be the center of the fourth sphere, $R$ be its radius, $H$ be the height of the prism we are looking for, $a$ be the side of the base of the prism, and $h$ be the height of the regular triangular pyramid $O O_1 O_2 O_3$ with vertex $O$ (Fig.1). Consider the orthogonal projection of the prism and the given spheres onto the plane of the base of the prism (Fig.2). We obtain three circles of radius $r$ touching the sides of an equilateral triangle with side $a$, and touching each other, as well as a circle of radius $R$ inscribed in this triangle. We have:

$$
\begin{gathered}
a=2 r+2 r \sqrt{3}=2 r(1+\sqrt{3}) \\
R=\frac{a \sqrt{3}}{6}=\frac{2 r(1+\sqrt{3}) \sqrt{3}}{6}=\frac{r(1+\sqrt{3}) \sqrt{3}}{3}=r\left(1+\frac{\sqrt{3}}{3}\right)
\end{gathered}
$$

The side of the base of the regular triangular pyramid $O O_1 O_2 O_3$ is $2 r$, and the lateral edge is $r+R$. Therefore,

$$
\begin{gathered}
h=\sqrt{(r+R)^{2}-\left(\frac{2 r \sqrt{3}}{3}\right)^{2}}=\sqrt{R^{2}+2 \pi R-\frac{\rho^{2}}{3}}= \\
=\sqrt{\left(1+\frac{\sqrt{3}}{3}\right)^{2}+2\left(1+\frac{\sqrt{3}}{3}\right)-\frac{1}{3}}=r \sqrt{3+\frac{1 \sqrt{3}}{3}}=\frac{1}{3} \sqrt{27+12 \sqrt{3}}
\end{gathered}
$$

Therefore,

$$
\begin{gathered}
H=r+h+R=r+\frac{1}{3} r \sqrt{27+12 \sqrt{3}}+r\left(1+\frac{\sqrt{3}}{3}\right)= \\
=\frac{1}{3} r(6+\sqrt{3}+\sqrt{27+12 \sqrt{3}})
\end{gathered}
$$

## Answer

$\frac{1}{3}(6+\sqrt{3}+\sqrt{27+12 \sqrt{3}})$.