pack(weights, box_limit) assigning items (kg) to boxes using first-fit: place each item into the first existing box it fits, else open a new box. Return the list of boxes (each a list of weights). Items above the limit raise ValueError. (First-fit isn't optimal — say so — but it's the interview standard.)pack([4, 8, 1, 4, 3], 10)
[[4, 1, 4], [8], [3]]
Each item drops into the first box with room.
Track remaining capacity per box.
Sum the box to test fit, or keep a parallel totals list.