🧭 Do not search for the first 15 minutes. When stuck: re-read the requirements → define I/O → choose the data structure → trace a small example by hand → write code.
Implement build_inventory(operations), which applies stock movements in order to
produce the final inventory. Reading the rules precisely is the whole problem.
operations = [
("apple", "add", 10),
("apple", "remove", 3),
("banana", "add", 5),
("apple", "add", 2),
]
Each entry is (item, "add"|"remove", quantity) and the quantity is a positive integer.
add increases stock; remove decreases it.remove that would drive stock negative is ignored entirely. You do not
deduct what is available — you skip the whole operation.{"apple": 9, "banana": 5}
Implement build_inventory(operations).
remove on an item that was never stocked is ignored.