leovene / Velozient

Velozient Test

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Velozient

Velozient Test

Well, I tried several ways to get the result of the Output.txt that came with the project's zip file, but I couldn't figure out how to use that Input.txt and get the Output.txt as a result. I added both files to the project's Solution in case you want to check which files I'm talking about. They are the same examples found in the PDF, however, the result didn't make any sense to me. I didn't understand if the drones were loaded based solely on weight, which wouldn't yield that result, nor is it in alphabetical order, nor by the number of trips. In short, I couldn't find a solution that gives that result, so I did what I could: the drones load the cargo from the locations as long as they have available weight capacity. They will make trips until all locations are exhausted.

Regarding the project, I created it as an API where you only need to initialize the project with Visual Studio 2022 installed and .NET 7. With these requirements met, simply run the project and Swagger will open. Click on 'Try it out' and then on 'Upload File'. Provide a valid input, and it will give you a result. I initially planned to include unit tests and more validations, but due to the time spent on the OptimizeDeliveries method, I had to leave those items aside. In any case, I did the best I could.

First, the method initializes the DeliveryOutput objects for each drone in the input list, adding them to the optimizedDeliveries list. Then, a while loop iterates until there are no locations left in the input list. Inside the while loop, a foreach loop iterates over each drone. For every drone, the method finds the corresponding DeliveryOutput object in the optimizedDeliveries list. Then, it initializes a new Trip object and calculates the remaining weight capacity for the drone. Next, the method filters the input locations to find candidate locations that the drone can visit, based on the remaining weight capacity. It sorts these candidate locations in descending order of package weight. The code enters another while loop, iterating until there are no candidate locations left. Inside this loop, the method selects the best location (the one with the highest package weight) and adds it to the current trip. It also updates the remaining weight capacity and removes the location from the input list. Then, the code recalculates the candidate locations based on the updated remaining weight capacity. Once there are no more candidate locations, the method checks if the current trip has any locations. If so, it adds the trip to the corresponding DeliveryOutput object's list of trips. The while loop continues until all locations have been assigned to trips. Finally, the method returns the optimized list of DeliveryOutput objects, which represent the delivery schedule for all drones.

About

Velozient Test


Languages

Language:C# 100.0%