Skip to content

pfkong/hoovermover

Repository files navigation

hoovermover.js

hoovermover.js is a fantastic way to move an automated hoover for cleaning virtual dirt in an input file!

Prereqs

  1. Download hoovermover.js and at least input.txt into a directory of your choice. Optionally, download any of the other .txt input files.
  2. node.js must be available in the running environment, so that the node command is available.
  3. Files hoovermover.js and input.txt are in the same directory.
  4. input.txt should abide the format specified below.

Usage

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 the Program

Single Input File / No Input File

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

Multiple Input Files

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

input.txt Format

  1. 1st line: Coordinates representing the size of the room.
  2. 2nd line: Coordinates representing the starting position of the robotic hoover.
  3. Any following coordinates represent patches of dirt in the room that could be potentially cleaned by the hoover.
  4. 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

About

Cleaning rooms with (hopefully) clean code.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published