Question: PYTHON Made some change help with other changes # Given a schedule of flight departure times and arrival times, write # a program which determines

PYTHON Made some change help with other changes

# Given a schedule of flight departure times and arrival times, write # a program which determines the maximum number of flights in the air at any # one time. # # In this scenario, you run an airport and are responsible for hiring pilots # to manage incoming and outgoing flights. There is a strict requirement that # you must have at least one pilot for each flight concurrently in the air. # # For example, if Flight A takes off at 9AM and lands # at 11AM, Flight B takes off at 10AM and lands at 1PM, and Flight C takes off # a 3PM and lands at 5PM then from the hours of 9AM-10AM one flight will be in # the air, from 10AM-11AM two flights will be in the air, from 11AM-1PM one # flight will be in the air, from 1PM-3PM no flights will be in the air, and # from 3PM-5PM one flight will be in the air. This flight schedule can be # visualized as follows: # # Sample Schedule # --------------- # DEPART ARRIVE # 9:00AM 1:00PM # 10:00AM 11:00AM # 3:00PM 5:00PM # # ________ # | | # | 2 | # -----| |---------- ----------- # | | | | # | 1 | 1 | | 1 | # ------------------------------------------------ # 9:00AM 11:00AM 1:00PM 3:00PM 5:00PM # # # FILE FORMAT # ----------- # " " # " " # " " # " " # " " #

def make_file(filename): flights = [ "1412901761 1412901766", "1412901569 1412901810", "1412901773 1412901811", "1412901424 1412901724", "1412901597 1412901632", "1412901614 1412901791", "1412901695 1412901732", "1412901749 1412901815", "1412901681 1412901690", ]

# Write data with open(filename, "w") as f: f.write(' '.join(flights)) f.flush()

# make_file("flights.txt")

flights = [ "1412901761 1412901766", "1412901569 1412901810", "1412901773 1412901811", "1412901424 1412901724", "1412901597 1412901632", "1412901614 1412901791", "1412901695 1412901732", "1412901749 1412901815", "1412901681 1412901690", ]

flight_events = [] for flight in flights: arrival, departure = flight.split(' ') # print(arrival + " " + departure) flight_events.append((int(arrival), 1)) flight_events.append((int(departure), -1)) print(flight_events)

# Sort list

# Parse list and calculate max

# Print max

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!