Skip to content
No description, website, or topics provided.
Branch: master
Clone or download
Pull request Compare This branch is even with fluency-in:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
LICENSE
README.md
robot_simulator_test.rb

README.md

Ruby: Robot Simulator

Write a robot simulator.

A robot factory's test facility needs a program to verify robot movements.

The robots have three possible movements:

  • turn right
  • turn left
  • advance

Robots are placed on a hypothetical infinite grid, facing a particular direction (north, east, south, or west) at a set of {x,y} coordinates, e.g., {3,8}, with coordinates increasing to the north and east.

The robot then receives a number of instructions, at which point the testing facility verifies the robot's new position, and in which direction it is pointing.

  • The letter-string "RAALAL" means:
    • Turn right
    • Advance twice
    • Turn left
    • Advance once
    • Turn left yet again
  • Say a robot starts at {7, 3} facing north. Then running this stream of instructions should leave it at {9, 4} facing west.

The tests use the Minitest testing framework. To install it run the command:

gem install minitest

Run the tests with the ruby command:

ruby robot_simulator_test.rb

Resources

If you have never used Minitest, check out Intro to TDD tutorial from Jumpstart Lab.

Source

Inspired by an interview question at a famous company.

This exercise is from the Ruby track on Exercism

You can’t perform that action at this time.