Implement public List buildMostOptimalTrip() to resolve as many customer complaints as possible: keep all orders for the same customer in a single trip (unless they can't all fit), prioritize Subscriber orders so they ship more quickly, never send orders marked fragile in the same trip as orders marked hazardous, and always move perishable goods directly to the front of the queue. Feel free to add other optimizations (e.g. multi-zone trips); document your data-structure decisions and decompose the code appropriately.
Asked in the Byteboard Code Implementation Exercise, Task 3 of the readme. Competing constraints are expected, and you are not expected to finish every possible optimization.
def buildMostOptimalTrip(orders):
orders is a list of order objects, each represented as a JSON object with fields: customerId, isSubscriber, isFragile, isHazardous, isPerishable, and zone.
Return a list of orders in the chosen trip order. Preserve all valid orders, keep each customer's orders together when possible, and apply the priority rules above.
def buildMostOptimalTrip(orders):