A simple command line application designed to accept delivery locations and find a route to navigate to all of them. This application is written in Typescript (Javascript).
Before starting, please ensure that all dependencies are installed.
- Node (8 or above) and NPM
You can run this application by doing the following.
Before running the application, you must first install all dependencies using NPM. Since this is a Typescript
application, you must also transpile the code into Javascript before executing it. Once complete, a runnable
version of the code will be saved in the ./dist
directory where it can be run.
npm install && npm run build
You can now run the application according to the guide in the Execution section below. You can also just copy the following to make it easier to get started. For more detail, keep reading.
npm run build && ./dist/pizzabot.js "5x5 (0, 0) (1, 3) (4, 4) (4, 2) (4, 2) (0, 1) (3, 2) (2, 3) (4, 1)"
Once setup, you can run the ./dist/pizzabot.js
command. It takes a single argument in the following form.
./dist/pizzabot.js "NXxNY (AX, AY)[ (BX, BY)...]"
Where the following fields may be specified.
NX
: The size of the grid, on theX
axis (horizontal).NY
: The size of the grid, on theY
axis (vertical).*X
: The X coordinate of a delivery location on the grid, where 0 is the origin.*Y
: The Y coordinate of a delivery location on the grid, where 0 is the origin.
However, there are some restrictions.
NX
: Must be an integer value greater than0
.NY
: Must be an integer value greater than0
.*X
: Must be an integer value,0
or greater, and less thanNX
.*Y
: Must be an integer value,0
or greater, and less thanNY
.
You must specify at least one delivery location. Here is an example to get you started.
./dist/pizzabot.js "5x5 (1, 3) (4, 4)"
This command will create a 5x5 delivery grid with two delivery locations - the first at X=1,Y=3 and the second at X=4,Y=4.
4 | | | | |X|
3 | |X| | | |
2 | | | | | |
1 | | | | | |
0 | | | | | |
-----------
0 1 2 3 4
Upon execution, this command will output a string of letters that indicate directions from the origin to each delivery location on the grid. Each step in the directions will be one of the following.
N
: Move north (up)S
: Move south (down)E
: Move east (right)W
: Move west (left)D
: Make a delivery
So, for the example above, the program could produce the following result.
ENNNDEEEND
This program comes packages with a test suite that you can fun as follows.
npm run test
Once run, you can view coverage reports in the ./coverage
directory.