Hello and welcome to this programming kata.
This kata consists of several parts where you should solve one part before you look at the next.
While you could speed through this kata by just implementing the requirements as quickly as possible, the intention of this kata is to practice Test Driven Development and as such you're recommended to think about this as production code and write proper tests for your implementation.
Where appropriate, an example will be shown to better explain the problem. These examples are perfect for an initial test case. I do recommend that you write more tests than just based on the example though, the aim, after all, is to drive development by passing tests.
Good luck!
/Raniz
This kata is a variant of the Mars Rover kata that can be found in various places around the internet.
Your task in this kata is to implement the navigation system for a very simple rover that can land on Mars.
Implement a simple rover that can move forwards and backwards on a flat plane. The rover has a position (x, y) and can receive commands 'F' (forward) and 'B' (backward). The rover starts at (0, 0) facing north.
Example: Starting at (0, 0), the command FF moves the rover to (0, 2).
The rover can now rotate left and right using commands 'L' (left) and 'R' (right). The rover can face one of four directions: North, East, South, or West. Rotation changes the direction but not the position.
Example: Starting at (0, 0) facing North, the command RFR turns right (facing east), moves forward to (1, 0), then turns right again (facing south).
The world now wraps around at the edges. When the rover moves beyond the boundaries of the world, it appears on the opposite side. Assume the world grid is 10x10 units
The world is now a sphere. East-West wrapping works as before, but North-South movement has the rover "come down on the other side" - e.g. when crossing the north pole, the rover continues in the same direction but appears on the opposite longitude facing south.
Instructions can now have numbers in front of them, meaning they should be repeated that many times. For example, 3F is equivalent to FFF.
Instructions now consist of two lines. The first line specifies the starting position of the rover. The second line specifies the instructions to follow. The format of the position line is <x>,<y><direction> and the format of the instructions line is a series of commands as before.
Example:
5,7N 2FRFL3BMeans that the rover starts at (5, 7) facing North.
Instructions now consist of three lines. The first line specifies the size of the world in the format <width>x<height> The second and third lines specify the starting position of the rover and the instructions, just like before.
Example:
36x18 7,16 2FRFL3BMeans that the rover starts at (7, 16) facing south in a world that is 36 units wide and 18 units tall.
Instructions now consist of four lines. The third line now specifies obstacles, moving the instructions to the fourth line.
Obstacles are specified as a comma-separated list of coordinates. For example, "1,2,3,4,5,6" means that there are obstacles at (1, 2), (3, 4), and (5, 6).
If an instruction would cause the rover to hit an obstacle, that instruction is ignored.
Example: With the rover positioned at (5,5) facing north and an obstacle at (5,6), the instructions FFLF would place the rover at (4,6) facing west.