Here's the problem: Given 4 groups of students of sizes A, B, C and D, and a total of k chaperones, devise an algorithm for assigning chaperones to students in near-equal proportions.
You can't just give the groups k*A/N, k*B/N, k*C/N, k*D/N chaperones, because the number of chaperones has to be a positive integer. And you can't just round, because then you might not get the right number of chaperones. So my idea is that you throw out the fractional part, and give the integer part to each group, so do integer division. Then you might have some left over chaperones, but at most 3, so give them to the groups with the biggest remainders.
Then, the interviewer pointed out that there's a problem with this. If you add another chaperone, so increase k to k+1, then it can happen that one of the groups actually loses a chaperone this way. She gave me an example, but I don't remember it.
Can anyone come up with an algorithm that avoids this problem?