Skip to content

Instantly share code, notes, and snippets.

@swalke16
Last active July 20, 2017 14:38
Show Gist options
  • Save swalke16/cbc8fd10180d9d04d682 to your computer and use it in GitHub Desktop.
Save swalke16/cbc8fd10180d9d04d682 to your computer and use it in GitHub Desktop.
Robot Controller Exercise

#Assignment:

Create a controller for a robot. The controller can respond to 4 commands corresponding to directions of movement (Forward, Back, Left, Right) and should maintain state of the current speed of travel.

Work in whatever language is comfortable for you. This is a test to see how you think about solving problems, not how well you know a specific technology. Show the results of your work either by writing unit tests, or making the controller interactive by accepting input and producing output to your medium of choice (console, web page, etc...).

Forward
Left 0 Right
Back

##Requirements:

  1. Controller starts at rest, speed: 0, direction: none.
  2. Controller can issue four directional instructions (Forward, Back, Left, Right).
  3. When at rest, instructions to move in a certain direction will set direction to that direction and speed to 1.
  4. When moving, instructions to move in the same direction as currently moving increment speed in that direction by 1.
  5. When moving, instructions to move in the opposite direction as currently moving decrement speed in the current direction by 1. If the result of the decrement is that the speed is 0 the controller is now at rest, and the instructions for moving from rest apply.
  6. When moving, Instructions to move in a perpendicular direction to current direction will change direction to that direction and speed to 1.
  7. When moving, once reaching speed level four in a given direction further instructions to move in that direction return speed to 0 and directon to "none".
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment