Cube Travel Programming Challenge

Level : Easy
You have a Unit cube (side of 1 unit) with the origin at A(0,0,0). The other co-ordinates could lie along the positive or negative X, Y and Z axis so as to form a cube.
e.g. A(0,0,0), B(1,0,0), C(1,1,0), D(0,1,0), E(0,0,-1), F(1,0,-1), G(1,1,-1), H(0,1,-1). You need to write code that given any two points (source, destination) in the cube should output the minimum path to reach the destination from the source traveling only along the edges. (Source and destination will always be different points)

Input

The first line of the input gives the number of test cases to be executed. For each test case the first line would give 'n' the number of inputs for that test case. The next line would define the co-ordinates of the cube with a semi colon to separate each coordinate. The co-ordinates are ordered form A- H. The next 'n' lines gives the input points to traverse for that test case.

Output

The output must be a series of command (left,right, up, down, forward, backward) to reach the destination from the source. In case multiple solution are possible then the ordering must be in this order only - left,right, up, down, forward, backward

Example

Input:
2 1 0,0,0;1,0,0;1,1,0;0,1,0;0,0,-1;1,0,-1;1,1,-1;0,1,-1 A F 3 0,0,0;1,0,0;1,1,0;0,1,0;0,0,1;1,0,1;1,1,1;0,1,1 A B C A A G

Output:
Case #1: right,backward, Case #2: right, left,down, right,up,forward,
The first line of the input gives the number of test cases that is 2. The first test case has 1 input case. The next line (line 3) gives co-ordinates of the cube. Line 4 gives the test case namely traverse the point A to F. The output for this case should now be self explanatory. The next set of test case begins at line 2.

Cube Travel Programming Challenge

www.quiz4j.com
18 October 2009 13:18
never
13
2863 days ago
2316 days ago
www.quiz4j.com
Upload a file instead
Java

Your submission



waiting...

Find more challenges on Scarky.com
Powered by SPOJ Engine © Sphere Research Labs