All problems

Seed Cabinet Refill Requests Too Few Whole Packs

Level 2 · node · API · Whole-pack replenishment planning

Scenario

A fictional seed cabinet tracks the target and current envelope count for each variety. Restocks arrive only in whole packs, so the planner returns the fewest packs needed to meet the target. The request falls short when the shortage is not divisible by the pack size.

Requirements

Return the fewest packs that will meet or exceed the target. Inputs are [current count, target count, pack size]; counts are nonnegative integers and pack size is positive.

Acceptance criteria

  • Return the exact number when the shortage is divisible by the pack size.
  • For a remainder, return enough packs to reach the target.
  • Request one pack even if just one envelope is missing.
  • Return zero when stock already meets or exceeds the target.