Toy Robot Simulator (Crystal)

Description

Create an application that can read in commands of the following (textual) form:

PLACE X,Y,F
MOVE
LEFT
RIGHT
REPORT

Constraints

Example Input and Output

Example a

PLACE 0,0,NORTH
MOVE
REPORT

Expected output:

0,1,NORTH

Example b

PLACE 0,0,NORTH
LEFT
REPORT

Expected output:

0,0,WEST

Example c

PLACE 1,2,EAST
MOVE
MOVE
LEFT
MOVE
REPORT

Expected output

3,3,NORTH

Deliverables

Please provide your source code, and any test code/data you using in developing your solution.

Please engineer your solution to a standard you consider suitable for production. It is not required to provide any graphical output showing the movement of the toy robot.

Please do not put your name in any of the submitted code since this makes it harder for us to review your submission anonymously.

Installation

Add this to your application's shard.yml:

dependencies:
  toy-robot-crystal:
    github: sonna/toy-robot-crystal

Usage

$ bin/main

  REPORT
  0,0,NORTH

  MOVE
  REPORT
  0,1,NORTH

  EXIT

Or

$ bin/main spec/fixtures/example_b.txt

  0,1,NORTH
  2,1,EAST

Contributing

  1. Fork it ( https://github.com/[your-github-name]/toy-robot-crystal/fork )
  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

Contributors