main
1PROBLEM THREE: MARS ROVERS
2
3
4A squad of robotic rovers are to be landed by NASA on a plateau on Mars.
5This plateau, which is curiously rectangular, must be navigated by the
6rovers so that their on-board cameras can get a complete view of the
7surrounding terrain to send back to Earth.
8
9A rover's position and location is represented by a combination of x and y
10co-ordinates and a letter representing one of the four cardinal compass
11points. The plateau is divided up into a grid to simplify navigation. An
12example position might be 0, 0, N, which means the rover is in the bottom
13left corner and facing North.
14
15In order to control a rover, NASA sends a simple string of letters. The
16possible letters are 'L', 'R' and 'M'. 'L' and 'R' makes the rover spin 90
17degrees left or right respectively, without moving from its current spot.
18'M' means move forward one grid point, and maintain the same heading.
19
20Assume that the square directly North from (x, y) is (x, y+1).
21
22INPUT:
23The first line of input is the upper-right coordinates of the plateau, the
24lower-left coordinates are assumed to be 0,0.
25
26The rest of the input is information pertaining to the rovers that have
27been deployed. Each rover has two lines of input. The first line gives the
28rover's position, and the second line is a series of instructions telling
29the rover how to explore the plateau.
30
31The position is made up of two integers and a letter separated by spaces,
32corresponding to the x and y co-ordinates and the rover's orientation.
33
34Each rover will be finished sequentially, which means that the second rover
35won't start to move until the first one has finished moving.
36
37
38OUTPUT
39The output for each rover should be its final co-ordinates and heading.
40
41INPUT AND OUTPUT
42
43Test Input:
445 5
451 2 N
46LMLMLMLMM
473 3 E
48MMRMMRMRRM
49
50Expected Output:
511 3 N
525 1 E
53
54INSTRUCTIONS
55-------------
56open up a command prompt in the build folder:
57
58to run the tests:
59$ build tests
60
61to run the program:
62$ build run