# breaking it down medium

Popcorn vs. the Crowd

The popcorn machine makes m bags a minute. The crowd orders in waves. Sooner or later, the machine drowns. 🍿

You get m and the orders arriving each minute. Every minute: new orders join the waiting pile, the machine clears up to m of them. Print the first minute (1-based) that ends with orders still waiting — or kept up if the machine survives.

Example:

Input: m = 3, orders = [2, 3, 5, 1] Output: 3

Minute 1 gets 2 orders, the machine clears all 2 (0 left). Minute 2 gets 3, cleared (0 left). Minute 3 gets 5, but the machine only clears 3, leaving 2 waiting — the first minute that ends with orders still waiting.

💡 need a hint?

brk-popcorn-crowd.py🔒 given lines are locked — write your code in between
loading...