![]() |
|
Don't ask to ask, just ask | |
PerlMonks |
Re: x objects in y containers where all objects are used (multinomial coefficients)by repellent (Priest) |
on Nov 09, 2009 at 20:42 UTC ( #806018=note: print w/replies, xml ) | Need Help?? |
This is a multinomial coefficients problem. The assumptions are:
mult_coeff(3, qw(a b c d e)); yields 150 results, which corresponds to the math:
for combinations of 1-2-2, 2-1-2, 2-2-1, 1-1-3, 1-3-1, 3-1-1. nck_with_leftover() should be memoized for performance. A solution:
In Section
Seekers of Perl Wisdom
|
|