9 identical squares of side 2 units are separated by empty strips also of 2 units width.

What is the shortest route from A to B, assuming you can only go around the edges of the squares?

Now, consider 27 identical cubes of side 2 units which are separated by corridors also of 2 units width. What is the shortest distance from A to B?