MHB A simple (?) combinatorial problem

  • Thread starter Thread starter lfdahl
  • Start date Start date
Click For 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!
 
There is a nice little variation of the problem. The host says, after you have chosen the door, that you can change your guess, but to sweeten the deal, he says you can choose the two other doors, if you wish. This proposition is a no brainer, however before you are quick enough to accept it, the host opens one of the two doors and it is empty. In this version you really want to change your pick, but at the same time ask yourself is the host impartial and does that change anything. The host...

Similar threads

  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 19 ·
Replies
19
Views
3K
  • · Replies 5 ·
Replies
5
Views
2K
Replies
3
Views
1K
  • · Replies 5 ·
Replies
5
Views
2K
Replies
29
Views
4K
  • · Replies 2 ·
Replies
2
Views
1K
  • · Replies 5 ·
Replies
5
Views
2K