No paths can do better than an analogous to
f''
's diagonal path, for hypercubes of any dimension. Without loss of generality, let's assume the side length equals one.
To make the diagonal path, you select one edge, find an adjacent (touching) edge perpendicular to the previous one, and another one perpendicular to both, and the fourth one perpendicular to the first three, and so on, until an edge is reached which contains the endpoint. Every edge changes one coordinate from zero to one, or one to zero, and since they are all perpendicular, it's a different one each time, so no coordinates are changed back to zero, and we're guaranteed to reach the opposite vertex.
In this way, there are $n$ of them, where $n$ is the number of dimensions. In an isometric map, each edge shares one face with the previous one, and no three edges are on the same face. This is enough to show that they form a zig-zag line, and the optimal path is obtained by linking the two extremities (proven later):
Moreover, for even $n$ we have a chart with equal number of horizontal and vertical edge intersections (or displacements), while for odd $n$ they differ by $1$.
We also see that any path, in its chart, intercepts the vertical and horizontal edges at least $n$ times, one for each coordinate changed to $1$ (same could be said about those increasing from $0$).
Now take a isometric chart and consider the dimensions, $dx$ and $dy$, of the bounding rectangle. Consider those with $dx+dy$ equal to $n$.
The squared length of a straight line from one corner to another of the rectangle ($dy^2 + dx^2$) is minimum when $dx$ is closest to $dy$, since it is equal to the square of their sum (a constant) minus twice their product (maximum when they're closest):
$$dx^2 + dy^2 = (dx+dy)^2 - 2dxdy$$
An optimal solution is $dx=dy$ if $n$ is even and $dx=dy+1$ otherwise. Our diagonal is the shortest curve bounded by a rectangle*, so it is optimal between every curve bounded by a rectangle of equal $dx+dy$:
Since the line must touch the four edges, we can reflect its pieces over the intersections to show that it is greater than the diagonal*
Rectangles with $dx+dy$ greater than $n$ have also greater diagonals, since by decreasing $dx$ or $dy$ we can make a shorter path which has a sum of $n$, and, thus, is greater than or equal to our diagonal.
So our diagonal solution, presented above, is the shortest in any rectangle that has $dx+dy$ no less than $n$. Now it only remains to show that smaller rectangles don't lead to optimal paths.
Every optimal path in a rectangle with semiperimeter ($dx+dy$) smaller than $n$ has to cross at least $n$ edges, moving one unit vertically or horizontally (or both) each time.
However, if this was done monotonically, $dx+dy$ would be greater than or equal to $n$. So it eventually runs in the opposite direction. Since the path is straight inside squares, the change happens at an edge or corner.
But if all turns were in the corners, then the paths after the turning points could be reflected vertically or horizontally in the chart one at a time while preserving length, until there is a monotonic path.
This path would then lie in a rectangle of semiperimeter $n$ or more, so would need to be greater or equal in path length to our diagonal solution. If any turn is at an edge, then the path is also not optimal. So there is no such optimal path.