Problem 1115. USC Fall 2012 ACM: Driving the Rover
This Challenge is to solve Question E, Driving the Rover, of the USC ACM Fall 2012 Contest.
The Rover is sent a Series of commands. Your task is to emulate the Rover response to the sequence and determine its "final position", [x,y]. The "final position" is the Rover location 1 second after the final command.
Initial conditions are Rover Stopped and Facing +Y. Commands are processed at 1 second intervals
Commands and their attributes: FORWARD: Starts rolling forward at 1 cm/s BACKWARDS: Roll backwards at 1 cm/s FASTER: Increase forward speed by 1 cm/s up to 5 cm/s SLOWER: Decrease forward speed by 1 cm/s down to 0 cm/s. At 0 cm/s Rover is "Stopped" STOP: Halts rover movement RIGHT: Turn rover 90 degrees to the right LEFT: Turn the rover 90 degrees to the left NOOP: No change in anything
Commands FORWARD, BACKWARDS, RIGHT, LEFT only take effect if the rover is stopped. A moving rover ignores these commands.
Commands FASTER and SLOWER only take effect if the rover is moving forward.
Input: [Cell array of Rover Commands]
Output: [x, y ]; Final Position 1 second after last command;
The full USC data file
Example:
Input: {'FORWARD' 'RIGHT' 'STOP' 'RIGHT' 'FORWARD' 'FASTER'}
Output: [3 2] as the first RIGHT is ignored
A Contest Drive solution. Time to Solve: 9 minutes. Start.
This is predecessor to the Martian Pits Challenge.
Solution Stats
Solution Comments
Show commentsProblem Recent Solvers7
Suggested Problems
-
4076 Solvers
-
163 Solvers
-
553 Solvers
-
Magic is simple (for beginners)
9187 Solvers
-
Count letters occurence in text, specific to words with a given length.
165 Solvers
More from this Author308
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!