You are reading a single comment by @moth and its replies. Click here to read the full conversation.
  • I think i've got it now?

    If you are allowed up to k toppings, then you can pick a combination of m (m <= k) toppings from the n available, then distribute up to k-m 'extras' among the m toppings (e.g convert bacon & mushroom to bacon and tripple mushroom (4 toppings)).

    My textbook tells me* there are (e+m-1)!/e!(m-1)! ways of sharing out e extras among the m toppings chosen.

    So with n possible toppings and k max toppings per pizza:

    sum from m = 1 to k { sum from e = 0 to k-m { n!(e+m-1)! / (n-m)!m!e!(m-1)!}}

    • 1 for the null pizza

    • The permutations formula n! only works if all n items are distinguishable. If m of them are identical then you need to divide by the m! ways they can be arranged. Putting e balls into m boxes is equivalent to picking a permutation of e identical balls and m-1 identical box-dividers.

About

Avatar for moth @moth started