Chapter 10 - Python Quest
Queues
Serve the oldest waiting item, rotate turns, manage work limits, and explore in waves.
Cafeteria Line
The cafeteria has a line of kids already waiting. New arrivals join the back before the helper serves one kid from the front.
Write cafeteria_line(line, arrivals) so it returns [served, remaining]. served is the first kid served, or "nobody" when the queue is empty. remaining is the queue after new arrivals join and one kid is served.
Sample checks
cafeteria_line(["Mia","Sam"], ["Noor"])returns["Mia",["Sam","Noor"]]Explanation: Noor joins behind Mia and Sam; Mia has waited longest, so Mia is served and Sam then Noor remain
cafeteria_line([], ["Ava","Leo"])returns["Ava",["Leo"]]Explanation: the line starts empty, Ava arrives before Leo, so Ava reaches the front and Leo remains
Hint
Hints are ready when you want one.
Lesson reference
Review: Add at the back, remove at the front
Your Python
cafeteria_line
Judge
Ready
Run your code when it feels ready.
