Generate distribution plans
A distributor has total_cases identical cases to send out this week and must place every one of them. store_names lists the stores in delivery order, and store_caps[i] is the most cases store i has room for, which may be zero. A plan gives every store a whole number of cases, from zero up to its own cap, and the shares add up to total_cases exactly. Return every plan as a string: each store name, an equals sign, then its share, joined by a comma and a space, so two stores read as "north=1, south=2". Build the plans by giving the first store zero cases first, then one, and so on up to what it can take, recursing on the cases that are left, so the plans come back in ascending order of the first store's share. Return an empty list when no plan fits, and when there are no stores. There are at most 6 stores.
list_store_allocations(store_names: list[str], store_caps: list[int], total_cases: int) → list[str][["north","south"],[2,2],3]out["north=1, south=2","north=2, south=1"][["north","south"],[2,2],0]out["north=0, south=0"][["north","south"],[1,1],5]out[]State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
[["north","south"],[2,2],3]["north=1, south=2","north=2, south=1"]not run yetsample[["north","south"],[2,2],0]["north=0, south=0"]not run yetsample[["north","south"],[1,1],5][]not run yetsample