| ||You are given a cube with side length S and vertices at (0,0,0), (0,0,S), (0,S,0), (S,0,0), (S,S,0), (S,0,S), (0,S,S) and (S,S,S). You are also given two points (x1,y1,z1) and (x2,y2,z2) on the faces of the cube. The distance between the points on the cube is defined as the minimal length of a polygonal curve which connects the two points. Each segment of that polygonal curve must be on a face of the cube, parallel to one of the cube's edges. The following image shows two pairs of points, connected with the shortest polygonal curves.
Return the distance between the given points.
|Parameters:||int, int, int, int, int, int, int|
|Method signature:||int calculate(int S, int x1, int y1, int z1, int x2, int y2, int z2)|
|(be sure your method is public)|
|-||A polygonal curve is a connected sequence of line segments. It contains a sequence of vertices A1, ..., An, where each pair of consecutive vertices is connected by a line segment.|
|-||S will be between 1 and 100, inclusive.|
|-||x1, y1, z1, x2, y2, z2 will all be between 0 and S, inclusive.|
|-||Points (x1,y1,z1) and (x2,y2,z2) will belong to the faces of the cube.|
|The points are placed on the same face of the cube, so the shortest polygonal curve that connects them consists of two segments, for example, (2,2,0) - (2,3,0) - (3,3,0) (the red curve on the image).|
|The points are placed on adjacent faces of the cube (the blue curve on the image).|
|The points are placed on opposite faces of the cube.|