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

45.65% Correct | 54.35% Incorrect
Last Solution submitted on May 12, 2021

Solution Comments

Show comments

Problem Recent Solvers7

Suggested Problems

More from this Author294

Problem Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!