DWITE Online Computer Programming Contest, October 2010, Problem 2
How hard can it possibly be to put together a robot vacuum? Some gears, some motors, and it can all be controlled by an iPhone. Easy, done! Now, to test if this thing actually works... You find a narrow hallway to safely run experiments in; it looks something like this:
There are 5 spaces, marked by periods. Your robot, marked by an asterisk, starts out somewhere in this hallway, and can move left or right. Once it reaches either end, further attempts to move in that direction keep it in the same spot.
The input will contain 5 testcases. The first line will be a map, followed by 5 lines of directions – either to move left, or to move right.
The output will contain 5 lines, a map of the hallway with the final position of the robot after executing the instructions.
*.... R R R R L .*... L L L L L