So we load each of the largest boxes onto their own truck, and adjust our average for distributing the rest of them to the remaining trucks. Continuing with my scheme, we pick off the heaviest boxes for our next truck until it would tip us over the average. Now we have four relatively simple cases, we just need to pick the one that will bring us closest to the average. We could:
- Leave it as it, so we'll be under.
- Add the next largest box, then we'd be over.
- Add small boxes while we remain under the limit, or
- Add one more small box and go over.
We could sort through all of the boxes and try and find the best combination that would bring us closest to the average, but that could take a lot of fussing, and there is no guarantee that you wouldn't end up with some combination of boxes that would be way off of our target. Besides, this is supposed to be gone quickly. If we had a quantum computer, solving this problem would be a piece of cake, but we don't, so I'm just gonna code this scheme up and see what happens.