Solution (source code)

= Solution

On the cylindrical surface $r=R$, the <line element> is $ds^2=R^2d\theta^2+dz^2$. For a single-valued path parametrized by increasing $\theta$,
$$
\boxed{L[z]=\int_{\theta_1}^{\theta_2}\sqrt{R^2+z'^2}\,d\theta.}
$$
The integrand has no explicit $z$, so its <Euler-Lagrange equation> gives the constant conjugate quantity $z'/\sqrt{R^2+z'^2}$. Its <derivative> with respect to $z'$ is strictly positive, hence $z'$ itself is constant. The two endpoints determine
$$
\boxed{z(\theta)=z_1+\frac{z_2-z_1}{\pi}\left(\theta+\frac\pi2\right),\qquad-\frac\pi2\leq\theta\leq\frac\pi2.}
$$
This is a constant-pitch <helix> on the cylinder. To verify global minimality, unroll the cylinder with planar coordinates $(R\theta,z)$. The path becomes a straight line between points separated by $\pi R$ and $z_2-z_1$, so the <triangle inequality> for arc length gives
$$
\boxed{L_{\min}=\sqrt{\pi^2R^2+(z_2-z_1)^2}.}
$$
This is the standard description of <geodesics on a circular cylinder>.