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!
 
Hello, I'm joining this forum to ask two questions which have nagged me for some time. They both are presumed obvious, yet don't make sense to me. Nobody will explain their positions, which is...uh...aka science. I also have a thread for the other question. But this one involves probability, known as the Monty Hall Problem. Please see any number of YouTube videos on this for an explanation, I'll leave it to them to explain it. I question the predicate of all those who answer this...
I'm taking a look at intuitionistic propositional logic (IPL). Basically it exclude Double Negation Elimination (DNE) from the set of axiom schemas replacing it with Ex falso quodlibet: ⊥ → p for any proposition p (including both atomic and composite propositions). In IPL, for instance, the Law of Excluded Middle (LEM) p ∨ ¬p is no longer a theorem. My question: aside from the logic formal perspective, is IPL supposed to model/address some specific "kind of world" ? Thanks.
I was reading a Bachelor thesis on Peano Arithmetic (PA). PA has the following axioms (not including the induction schema): $$\begin{align} & (A1) ~~~~ \forall x \neg (x + 1 = 0) \nonumber \\ & (A2) ~~~~ \forall xy (x + 1 =y + 1 \to x = y) \nonumber \\ & (A3) ~~~~ \forall x (x + 0 = x) \nonumber \\ & (A4) ~~~~ \forall xy (x + (y +1) = (x + y ) + 1) \nonumber \\ & (A5) ~~~~ \forall x (x \cdot 0 = 0) \nonumber \\ & (A6) ~~~~ \forall xy (x \cdot (y + 1) = (x \cdot y) + x) \nonumber...
Back
Top