MHB A simple (?) combinatorial problem

  • Thread starter Thread starter lfdahl
  • Start date Start date
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!
 
Namaste & G'day Postulate: A strongly-knit team wins on average over a less knit one Fundamentals: - Two teams face off with 4 players each - A polo team consists of players that each have assigned to them a measure of their ability (called a "Handicap" - 10 is highest, -2 lowest) I attempted to measure close-knitness of a team in terms of standard deviation (SD) of handicaps of the players. Failure: It turns out that, more often than, a team with a higher SD wins. In my language, that...
Hi all, I've been a roulette player for more than 10 years (although I took time off here and there) and it's only now that I'm trying to understand the physics of the game. Basically my strategy in roulette is to divide the wheel roughly into two halves (let's call them A and B). My theory is that in roulette there will invariably be variance. In other words, if A comes up 5 times in a row, B will be due to come up soon. However I have been proven wrong many times, and I have seen some...
Back
Top