Codington
0 of 6 problems solved • 0%

Exercise prompt

Plan a Restock

A shop has a target stock level for each product. The number to order is the gap between the target and the current balance.

Example

A class compares attendance with the capacity of one room.

limits = {"studio": 12} booked = {"hall": 4} free = limits["studio"] - booked.get("studio", 0) print(free) # 12

Use the target dictionary to decide which keys matter. The second dictionary may lack one of those keys.

Your task

Implement restock_plan(stock, targets). Return a dictionary for target items below their target, mapping each item to the quantity needed. An item missing from stock has zero units. Omit items at or above target and items without targets.

restock_plan({"tea": 4, "soap": 6}, {"tea": 7, "soap": 5, "milk": 1}) # {"tea": 3, "milk": 1}