Coordinates can not be of negative value" means that the x and y coordinates of the rovers' positions on the mentioned surface cannot have negative values. In other words, the rovers cannot be positioned at locations with negative x or y values. This assumption helps define the boundaries of the area in which the rovers can move and explore on Mars.
indicates that the maximum values for the x and y coordinates of the grid (or plateau) on which the Mars rovers operate cannot be negative. This ensures that the grid's boundary is defined in a way that avoids negative coordinates and establishes a non-negative coordinate space for the rovers to navigate within. It's a constraint that helps maintain the validity of the grid's dimensions and prevents rovers from going beyond its specified boundaries.
-
Make you
rubyis installed locally. Visit this guide for installation steps using rbenv -
clone this repository to your local machine
-
navigate to the repository follow terminal
-
run the following command to start the commandline program
bin/mars_rovers {x} {y}Place
{x}and{y}with the sizr fo the grid (plateau) Keep in mind that (x,y) should be positive integersif
{x}{y}are not passed, the max grid defaults to (5,5) -
the command above result it permissions related issue, try running commnd to grant the script file permission, then run the script again.
chmod +x bin/mars_rovers
-
You can also run the script directly with ruby
ruby bin/mars_rovers
-
I have also published a ruby gem you can install and test it from there
gem install mars_rovers_dellan
ruby mars_rovers 5 5
-
You will be prompted to enter an intial position of a rover
x y N -
For example
1 2 N -
Next you will be prompted to enter the motion command of the format
LRML- turn leftR- turn rightM- move
-
Example command is
LMLMLMLMM -
The new location will be printed.
-
You can keep adding ass many rovers as you'd like
-
Use the
printcommand to output the locations for all the rovers added
