This is a solution for a proposed challenge that you can look at CHALLENGE.md
Before running either the entire solution or just the tests you must prepare a Elastich Search simple http service at your machine using Docker Compose. Run at root:
docker compose up -d
Install dependencies running:
yarn
Take a look at the examples below to understand the supported input format of the solution. The input format should look exactly how it is at the examples.
The solution receives three kind of parameters:
Parameter | Format | Meaning | Example | Rover data |
---|---|---|---|---|
Plateau/Grid dimensions | <INTEGER>, <INTEGER> | X limit and Y limit. The upper-right-corner limit. | 5,5 | No |
Rover starting position | <INTEGER>,<INTEGER>,<CHARACTER> | X position, Y position and orientation {where it is pointing to [should be N (North), S (South), W (West) or E (East)]} | 1,1,W | Yes |
Rover instructions | <CHARACTER[]> | The sequence of instruction that the rover should follow | LMRMLMLMLMR | Yes |
Running at your shell, the parameters should be separated by spaces and look like this:
yarn rover 8,8 1,2,N LMLMLMLMM
# 8,8 means a 9x9 [since the hardcoded lower-left corner (0, 0) is a valid position]
# 1,2,N is the rover starting position and orientation
# LMLMLMLMM is the instructions to rover where L means left, R means right and M means move
You can inform multiple rover data params to run two or more rovers in the same execution:
npm start 8,8 1,2,N LMLMLMLMM 3,3,E MRRMMRMRRM
Run the example 1 input from CHALLENGE.md
yarn example1
Run the example 2 input from CHALLENGE.md
yarn example2
Run both examples from CHALLENGE.md in the same execution
yarn examples
Store the log of the executions was part of the challenge. To check what data has been stored using you browser โ after running a pre-made or a custom example โ type at the url field: http://localhost:9200/input-logs/_search
or http://localhost:9200/output-logs/_search
.
The project has basic tests, you can run it by running:
yarn test