0
$\begingroup$

How many ways are there for a child to take 10 pieces of candy with 4 types of candy if the child takes at most 5 pieces of any type of candy?

$\endgroup$
1
  • $\begingroup$ This can be rephrased: How many solutions does $X_1+X_2+X_3+X_4 = 10,\quad X_i \leq5$ have? $\endgroup$ – Frank Vel Feb 11 '15 at 19:22
1
$\begingroup$

146 ways.

Found programatically:

void enumerate() {
int a1, a2, a3, a4;
int count = 0;

for (a1 = 0; a1 < 6; a1++)
for (a2 = 0; a2 < 6; a2++)
for (a3 = 0; a3 < 6; a3++)
for (a4 = 0; a4 < 6; a4++)
{
    if (a1 + a2 + a3 + a4 == 10)
    {
        count ++;
    }
}
cout << count << endl;
}
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.