A day at the bakery
All of the day's orders are waiting when the bakery opens, as
(priority, name) tuples with distinct priorities, where a smaller number
means more urgent. The bakery makes one order per hour, always the most
urgent one still waiting. Write schedule(orders, hours) that returns the
names made in the first hours hours, in order. If the bakery runs out of
orders early, the list is shorter.
schedule([(3, "bread"), (1, "cake"), (2, "rolls")], 2) -> ["cake", "rolls"]
schedule([(1, "cake")], 5) -> ["cake"]
import heapq
def schedule(orders, hours):
...