Your question is Flight Logs Aggregation. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
BCG X's flight-planning analytics pipeline receives flight logs from multiple routes. Implement a function that calculates the average duration, average ticket price, and total number of flights for an exact departure and destination pair.
The function receives logs, a list of dictionaries, plus departure and destination strings. Each log contains:
departure: airport code stringdestination: airport code stringduration_minutes: positive integerticket_price: non-negative numberReturn a dictionary with keys average_duration, average_ticket_price, and total_flights. Average values must be floating-point numbers. If no flight matches the route, return both averages as 0.0 and total_flights as 0.
Matching is case-sensitive, and only exact departure and destination matches count. Do not modify the input list.
def calculate_route_metrics(logs, departure, destination):