Shard Detail

kata-mars-rover v0.1.0

Mars rover kata from

Install & Use

Add the following code to your project's shard.yml under:

dependencies to use in production
- OR -
development_dependencies to use in development

  github: albertllousas/kata-mars-rover



I chose this one to learn and play a bit with Crystal language.

Since it is done in an earlier version of Crystal (0.25.1), language features could change.


Develop an api that moves a rover around on a grid.


  • You are given the initial starting point (x,y) of a rover and the direction (N,S,E,W) it is facing.
  • The rover receives a character array of commands.
  • Implement commands that move the rover forward/backward (f,b).
  • Implement commands that turn the rover left/right (l,r).
  • Implement wrapping from one edge of the grid to another. (planets are spheres after all)
  • Implement obstacle detection before each move to a new square. If a given sequence of commands encounters an obstacle, the rover moves up to the last possible point and reports the obstacle.


The solution is a mixed paradigm approach of object oriented programming and functional programming with pure data structures.

Installation & Troubleshooting

crystal -v
Crystal 0.25.1 (2018-06-30)

Install crystal lang following instructions here :


It is an API of rover, take a look on the test to see how it looks.


Given it is an earlier version of crystal, IDEs as idea are not supporting it well yet. I would recommend using with crystal packages.

run tests

crystal spec

format code

crystal tool format src/

To improve

  • Error handling: Crystal's way to do error handling is by raising and rescuing exceptions without typing methods, could be improved with a using a simple wrapper or a monadic structure
  • Mocking libraries: is not working with crystal 0.25.1, so it was not possible to mock


  1. Fork it (
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request