Algorithms - Induction (packing cups into boxes)

166 Views Asked by At

I need some assistance on this question. I honestly just have no idea where to go with this one.

Question: We have $n\cdot k$ cups. Each of these cups has one of the $k$ different colors. Assume $k$ boxes of size $n$ are available for packing these cups. Prove we can pack these cups in a way that each box has cups of at most two different colors. Use induction on $k$.

1

There are 1 best solutions below

2
On BEST ANSWER

I like this kind of problems. Here we go:

If $k=1$ the result follows immediately.

Let's assume the result is also true for all $k-1\geq 1$. Then, if we have $k$ boxes of size $n$ (and $k$ different colors). Put all the cups of one color (choosing a color for which you have $n$ or less cups) in a box and set it aside even if you don't fill the box completely (you can always do this, why?). After this, choose a color such that you have enough cups of that color to fill the box (you can always do this, why?).

This will leave us with $k-1$ boxes of size $n$ and $n(k-1)$ cups of $k-1$ colors. By hypothesis now we can fill all the boxes with cups of at most two different colors each.