https://github.com/luan/mars-rovers
Mars Rovers basic solution in plain ruby
https://github.com/luan/mars-rovers
Last synced: about 1 year ago
JSON representation
Mars Rovers basic solution in plain ruby
- Host: GitHub
- URL: https://github.com/luan/mars-rovers
- Owner: luan
- Created: 2012-04-28T17:59:09.000Z (about 14 years ago)
- Default Branch: master
- Last Pushed: 2022-02-08T23:45:32.000Z (over 4 years ago)
- Last Synced: 2025-02-01T07:44:15.942Z (over 1 year ago)
- Language: Ruby
- Size: 7.81 KB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Mars Rovers
I used RSpec for unit testing together with guard and guard-rspec for continuous testing.
I used Rake for running everything.
There are 3 rake tasks:
```
$ rake -T
rake batch # Run the app in batch mode
rake interactive # Run the app in interactive mode
rake spec # Run RSpec code examples
```
- The batch mode will run the example input from the specification.
- The interactive mode will expect user input, that could be eigher typed in the thermina
or directed from the command line with pipes or < assignments.
- The spec task runs all the unit tests
Example usage:
```
$ rake batch
=> 1 3 N 5 1 E
```
### plateau.txt
```
5 5
1 2 N
LMLMLMLMM
3 3 E
MMRMMRMRRM
```
```
$ rake interactive < plateau.txt
=> 1 3 N 5 1 E
```
```
$ rake interactive
5 5
1 2 N
LMLMLMLMM
3 3 E
MMRMMRMRRM
=> 1 3 N 5 1 E
```
I assumed that a rover can't go out of the plateau (one rover hits the edge won't go further).
I assumed that rovers can walk through each other (two or more rovers can occupy the same position).