cs-143 — The Shelf Replenishment

FieldValue
idcs-143
difficultyIntermediate
topicsinventory, greedy, trade-offs
lecturelecture-23
estimated time5-minute attempt + 10-minute discussion
prerequisiteslecture-17 (linear scans), lecture-19 (invariants)
objectivederive a restock rule that never empties a slot under a daily cadence constraint
solutionheld by the instructor; discussed after the attempt

Problem

A corner shop has 20 shelves. One assistant visits each shelf once per day, in a fixed order, and can restock only what fits in their cart (capacity 30 units). Each shelf sells a known number of units per day:

shelf:   A  B  C  D  E  F  G  H  I  J
per day: 9  5  7  3  8  2  6  4  5  6

(shelves K–T total 41 units/day more, same structure). A shelf must never reach zero during the day: sales happen after the assistant's visit. The cart is refilled to 30 units at the start of each day.

Your deliverables:

  1. The restock rule the assistant follows each day (in words, then as two lines of pseudocode).
  2. Worked check on shelf A: does your rule keep A stocked all day, every day, with daily visits? Show one day.
  3. The failure case: which shelf goes empty first if visits drop to every second day, and why the rule cannot save it?
  4. The trade-off sentence: capacity 30 vs daily cadence — which would you negotiate first, and what evidence for it?

If the problem is ambiguous anywhere, state the assumption you are making and carry on — a stated assumption is part of a good answer.

Examples

Solve for the worked instance first. Then ask what would change if one number, name, or condition were replaced by something stranger.

What to notice

Discussion starter

After the solution is revealed, the class spends five minutes on this prompt: "Management offers a second assistant who can start mid-day but carries only 15 units. Model the effect on your rule's binding constraint in two sentences — no full simulation needed."

Constraints and assumptions

Hints and extension