MHB A simple (?) combinatorial problem

  • Thread starter Thread starter lfdahl
  • Start date Start date
AI Thread Summary
The combinatorial problem involves distributing 20 identical items among 10 different persons, with each person allowed to receive between zero and five items. The Stars and Bars method is not applicable due to the item limit per person, making the problem more complex. A suggested solution is to programmatically enumerate all possibilities, which is feasible given the upper boundary of 6^10. A Python function was provided to calculate the number of distributions, yielding a result of 2,930,455. The original poster expressed gratitude for the assistance and plans to adapt the code for use in SciLab.
lfdahl
Gold Member
MHB
Messages
747
Reaction score
0
As simple as it seems, I still can´t figure out how to solve the following combinatorial problem:

In how many ways can 20 identical items be distributed among 10 (different) persons, when each person may have from zero to five items?

Thankyou in advance for any help, that can lead me on the right path ...
 
Physics news on Phys.org
lfdahl said:
As simple as it seems, I still can´t figure out how to solve the following combinatorial problem:

In how many ways can 20 identical items be distributed among 10 (different) persons, when each person may have from zero to five items?

Thankyou in advance for any help, that can lead me on the right path ...

Hey lfdahl,

It would be simple if we could apply the Stars and bars method.
But since we have a maximum of 5 items per person, I believe it's not so simple.
Simplest that I can come up with, is to programmatically enumerate all possibilities.
That should be doable since we have an upper boundary of $6^{10}$, which is still feasible.

In python:
Code:
""" Number of ways to divide o identical objects over p persons
where each person receives 0 to m objects.
"""
def recurse(o, p, m):
	if p == 1:
		return 1 if o <= m else 0
	n = 0
	for i in range(0, min(m, o) + 1):
		n += recurse(o - i, p - 1, m);
	return n;
	
print recurse(20, 10, 5);
Result is [M]2930455[/M].
 
I like Serena said:
Hey lfdahl,

It would be simple if we could apply the Stars and bars method.
But since we have a maximum of 5 items per person, I believe it's not so simple.
Simplest that I can come up with, is to programmatically enumerate all possibilities.
That should be doable since we have an upper boundary of $6^{10}$, which is still feasible.

In python:
Code:
""" Number of ways to divide o identical objects over p persons
where each person receives 0 to m objects.
"""
def recurse(o, p, m):
	if p == 1:
		return 1 if o <= m else 0
	n = 0
	for i in range(0, min(m, o) + 1):
		n += recurse(o - i, p - 1, m);
	return n;
	
print recurse(20, 10, 5);
Result is [M]2930455[/M].

Hey, I like Serena

Thanks a lot for your thorough answer to my problem!
Although I´m not familiar with python, I will see, if I can write your codes in SciLab.
I really appreciate your help!
 
I was reading documentation about the soundness and completeness of logic formal systems. Consider the following $$\vdash_S \phi$$ where ##S## is the proof-system making part the formal system and ##\phi## is a wff (well formed formula) of the formal language. Note the blank on left of the turnstile symbol ##\vdash_S##, as far as I can tell it actually represents the empty set. So what does it mean ? I guess it actually means ##\phi## is a theorem of the formal system, i.e. there is a...
Back
Top