Kodewick
開始學 →
基礎←→0 / 80

機場接人

#072基礎約 5 分鐘

接機屏上一行一班:航班號和到達時間,比如 "CA9 9:30"。寫 arrival_order(text),按到達時間從早到晚排,返回航班號。時間要變成「從 0 點起的分鐘數」再比(不然 "9:30" 會排到 "14:05" 後面)。到達時間都不一樣。

示例
arrival_order("MU5 14:05\nCA9 9:30\nZH2 9:05")→['ZH2', 'CA9', 'MU5']
arrival_order("")→[]
main.py
def arrival_order(text):
    flights = []
    for line in text.splitlines():
        code, time = line.split()
        h, m = time.split(":")
        # 在這裡寫:把 (分鐘數, 航班號) 放進 flights
    # 在這裡寫:把 flights 排好
    return [code for minutes, code in flights]
Ctrl + Enter 也能執行
結果

寫好了先點「執行」試試示例,沒問題再點「提交」。