hoovermover.js
is a fantastic way to move an automated hoover for cleaning virtual dirt in an input file!
- Download hoovermover.js and at least input.txt into a directory of your choice. Optionally, download any of the other .txt input files.
- node.js must be available in the running environment, so that the
node
command is available. - Files hoovermover.js and input.txt are in the same directory.
- input.txt should abide the format specified below.
node hoovermover.js [file, ...]
Inputs:
file: Name of file(s).
Outputs:
1. Input file name
2. Position of hoover
3. # of dirt spots hoovered
No file param assumes input.txt
.
Running node hoovermover.js
will run the program.
Using the input.txt provided in the repo as an example, the expected output is:
USER$ node hoovermover.js
[file: input.txt]
1 3
1
Running node hoovermover.js *.txt
will attempt to move all the hoovers across given files. Using all .txt files provided in the repo as an example:
Peters-MBP:hoovermover peterkong$ node hoovermover.js *.txt
[file: input.txt]
1 3
1
[file: test_hooverAll.txt]
1 0
3
[file: test_outOfBounds1.txt]
0 0
1
[file: test_outOfBounds2.txt]
4 4
0
- 1st line: Coordinates representing the size of the room.
- 2nd line: Coordinates representing the starting position of the robotic hoover.
- Any following coordinates represent patches of dirt in the room that could be potentially cleaned by the hoover.
- Last line is a string of cardinal directions that the hoover will attempt to move in (ordered left to right).
5 5
1 2
1 0
2 2
2 3
NNESEESWNWW