Problem 121504 · easy · Phase 01 Prerequisites & Setup

Warehouse Restock List

loops · conditionals · lists

Each entry of stock is [item, quantity, minimum]. An item needs restocking when its quantity is strictly below its minimum. Return a list of [item, needed] for every such item, where needed = minimum - quantity, in the same order as the input.

Examples

Input:  stock = [["nails", 3, 10], ["screws", 20, 10], ["glue", 5, 5]]
Output: [["nails", 7]]

Input:  stock = []
Output: []

Constraints

  • 0 <= len(stock) <= 1000, 0 <= quantity, minimum <= 10**4

Goals

  • Filter records that meet a condition while keeping their order
  • Compute a derived value (the shortfall) for each selected record
Starting Python…