# Shortest path on unit cube in $\mathbb{R}^n$

The unit cube in $\mathbb{R}^n$ is the set of points $(x_1,...,x_n)$ such that $0 \leq x_i \leq 1$ for all $1 \leq i \leq n$. The surface of this cube is the set of points of the cube such that at least one of the $x_i$ equals either $0$ or $1$. What is the shortest path to travel from $(0,0,...,0)$ to $(1,1,...,1)$ only along points on the surface of the cube?

In $\mathbb{R}^3$ the shortest path is $\sqrt{5}$, obtained by flattening the cube and drawing a diagonal.

However, what would the shortest path in $\mathbb{R}^n$ be?

The shortest path is then the straight path from $(0,0,\ldots,0,0)$ to $(0,\frac 12,\ldots, \frac 12,1)$ and from there the straight path to $(1,1,\ldots,1,1)$.
Both segments have length $\sqrt {1+\frac{n-2}4} = \frac 12\sqrt{n+2}$, so the length of the shortest path is $\sqrt{n+2}$