The Drone Delivery Program is a tool designed to optimize the assignment of deliveries to drones for efficient and cost-effective delivery operations. By intelligently sorting deliveries and drones based on weight and capacity, respectively, the program aims to minimize the number of trips required while maximizing the payload carried by each drone.
-
Input File: Prepare an input file in the data folder (
./data/input.txt
) containing the details of drones and deliveries. Each line should represent either a drone or a delivery, with specific formatting as follows:- Drones: Lines starting with
[Drone
indicate drone specifications, including name and capacity enclosed in square brackets. For example:[DroneA], [100]
. - Deliveries: Lines starting with
[Location
represent delivery locations and their respective weights, also enclosed in square brackets. For example:[LocationA], [20]
.
- Drones: Lines starting with
-
Running the Program: Execute the
main()
function in theindex.js
file to run the program. Ensure that Node.js is installed on your system. Run the following command in the terminal:node ./index.js
-
Output: After execution, the program will generate an output file in the data folder (
./data/output.txt
) containing the organized assignments of deliveries to drones. Each section in the output file corresponds to a drone and its assigned deliveries.
For a better understanding of the input and output formats, consider the following example:
Input (./data/input.txt
):
[DroneA], [100], [DroneB], [150],
[LocationA], [20] [LocationB], [30] [LocationC], [40]
Output (./data/output.txt
):
[DroneA]
Trip #1
[LocationC], [LocationB]
[DroneB]
Trip #1
[LocationA]
In this example, DroneA carries LocationC and LocationB in a single trip, while DroneB handles LocationA in a separate trip.
- Ensure that the input file follows the specified format to avoid errors in parsing.
- The program is designed to handle a maximum of 100 drones, as per business requirements.