A simple (?) combinatorial problem

  • Context: MHB 
  • Thread starter Thread starter lfdahl
  • Start date Start date
Click For Summary
SUMMARY

The combinatorial problem discussed involves distributing 20 identical items among 10 different persons, with each person receiving a maximum of 5 items. The solution requires a recursive approach, as the Stars and Bars method is not applicable due to the upper limit on item distribution. A Python function named recurse is provided, which calculates the total number of distributions, yielding a result of 2,930,455 ways. This method is feasible given the constraints of the problem.

PREREQUISITES
  • Understanding of combinatorial mathematics
  • Familiarity with recursive programming techniques
  • Basic knowledge of Python programming (version 3.x recommended)
  • Concept of the Stars and Bars theorem in combinatorics
NEXT STEPS
  • Learn about advanced combinatorial techniques and their applications
  • Explore Python recursion and optimization strategies
  • Investigate the SciLab equivalent for recursive functions
  • Study the Stars and Bars theorem in-depth for broader combinatorial problems
USEFUL FOR

Mathematicians, computer scientists, and programmers interested in combinatorial algorithms and recursive problem-solving techniques.

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!
 

Similar threads

  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 19 ·
Replies
19
Views
4K
  • · Replies 3 ·
Replies
3
Views
18K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 28 ·
Replies
28
Views
3K
  • · Replies 8 ·
Replies
8
Views
2K