I worked this one out for myself so it clearly
isn't that hard...
Before reading the answer can I interest you in a clue?
First consider the diagram:-
The problem phrased differently is that we
have to get from point A to point B only moving along the walls.
The shortest route is shown it is A-H-B where
H is the mid point of D-E.
The length of this route can easily be
calculated, assume the cube has sides of length 1 unit (it doesn't matter what
these units are, meters, feet, what ever) The distance A-H is the hypotenuse of a
triangle 1 x ½ a quick bit of pythag tells us that A-H equals sqrt(5/4).
Similarly H-B has the same length hence the total length is 2 x sqrt(5/4) this
is actually equal to the square root of 5
A-H-B = sqrt(5) = 2.236
A common wrong answer is to think the shortest route is A-C-B
or A-E-B or A-F-B etc. (they are all the same) this has a length of 1 + sqrt(2)
ie. about 2.414.
ETA: Some people have been confused by the diagram. I think possibly the line A-H looks like it might be the back edged of the cube, with H being the hidden corner. So we are absolutely clear I made a video, this time using Minecraft: