Build a tshirt distribution system
Show Description
Imagine you're working at a T-shirt factory and you manage orders by packing a bulk amount of shirts into a certain number of bags. For every order, you have a specification of how many bags you have to fill and a fixed number of shirts to fill them with. The requirement is to distribute the shirts in the bags as evenly as possible.
For example, if there are 100 shirts and 10 bags, then each bag will get 10 shirts. However, sometimes the shirt factory will have production errors, and it might produce the wrong number of shirts. It's not going to be 200 shirts instead of 100, but there will be some minor deviation from the original number.
Write a function to solve this problem. Define the function name, input parameters, and output type as you wish. The goal is to minimize the deviation of the number of shirts in each bag, i.e., distribute as evenly as possible, with the important aspect that only a single bag can have a different number of shirts. For example, if you have 10 bags and 103 shirts, then 9 bags can have 10 shirts, and the last bag can have 13 shirts. Here the deviation is 13 - 10 = 3, which is the minimum deviation.