The obvious route, up a foot, along the ceiling and down eleven, is 42 feet. Unfold the room so the path crosses five of the six faces, the end wall, the ceiling, a side wall, the floor and the other end wall, and it becomes a straight line of exactly 40.