Learning math in preparing for CS.

The third sentence implies that there are at most 2k+1 colors of candy (think about this for a bit, if you still can't see why I can clarify further). Since k is positive, there are at least 3 colors. Group the colors into 0 or more groups of 2 and 1 group of 3. You can assign 2n kids to each of the groups of 2 (hopefully this is obvious). You can assign 3n kids to the group of three colors in the following way. For each group of 3 kids k1, k2, k3, assign a group of 3 pairs of colors c1, c2, and c3. Give k1: c1, c2, k2: c2, c3, k3: c3, c1. Since you have 2n each of c1, c2, and c3, you have n pairs and hence can repeat this for 3n kids. It follows that the k = nc where c is the number of colors you have. We already know that there are at most 2k+1 colors, so there are at most (2k+1)n kids.

/r/learnmath Thread Parent