1

I found this problem in a textbook.

"In how many ways can 6 computers be allocated to 3 schools if each school receives at least one computer?".

Here is my logic, but I know something must be wrong. Out of the $6$ computers, I need $3$ computers to allocate to the $3$ schools so that I make sure that each school has a computer and the remaining 3 computers can go to any school.

First, I give $3$ computers to the $3$ schools to make sure each school gets one computer: There are $ C^3_6 = \frac{6!}{3!3!} = 20$ combinations possible.

Then there are $6! = 3 \times 2 \times 1 = 6$ ways in which those 3 computers can be allocated to those schools. Thus, $20 \times 6 = 120$.

Then, I still have $3$ computers that can go to any school. Thus,I still have $3^3 = 27$ ways. $120*27 = 3240$.

But this cannot be correct, because the total number of possibilities if we didn't have this restriction would be $3^6 = 729 < 3240$. What do I get wrong? Thank you. :)

N. F. Taussig
  • 79,074
  • 1
    Welcome to Math SE. Your post’s current title isn’t very informative, either to those of us who might be able to help you with your question or to others who might have a question similar to yours in the future but who wouldn’t be able to recognize that fact because your title is so vague. I encourage you to edit your post to make its title more specific and helpful. – Paul Tanenbaum Dec 22 '24 at 16:41
  • As is evident, you are overcounting. You will have to apply inclusion-exclusion to get the correct count – true blue anil Dec 22 '24 at 16:41
  • This problem is small enough that one can work it out by brute force, producing an exhaustive enumeration based on the widely useful stars-and-bars technique. – Paul Tanenbaum Dec 22 '24 at 16:54
  • I edited your title to make it specific to the problem you wish to solve. – N. F. Taussig Dec 23 '24 at 22:30

2 Answers2

3

Inclusion-Exclusion, as used in Robert Shore's answer, is generally the best approach, for this type of problem. That is because Inclusion-Exclusion generalizes well. See this article for an introduction to Inclusion-Exclusion. Then, see this answer for an explanation of and justification for the Inclusion-Exclusion formula.


Alternative approach.

For this specific problem, the numbers are small enough that the direct approach is also viable. In effect, this approach rehabilitates the approach taken in the posted question.

Based on the posted question, I am assuming that the computers are distinguishable, and the schools are distinguishable.

Shown below are all of the different ways of Integer Partitioning the number $~6~$ into exactly $~3~$ positive terms:

$$4 + 1 + 1, ~~~~3 + 2 + 1, ~~~~2 + 2 + 2. \tag1 $$

These $~3~$ partitions are mutually exclusive with each other. So, you can enumerate the number of different distributions associated with each partition, and then add these computations together.


$\underline{4 + 1 + 1}$

There are $~\displaystyle \binom{6}{4} = 15~$ ways of selecting which $~4~$ computers will be grouped together, and then $~3~$ ways of determining which of the $~3~$ schools will receive these $~4~$ computers.

Then, there are $~2~$ ways of distributing the $~2~$ remaining computers to the other $~2~$ schools, so that each school receives exactly $~1~$ of the $~2~$ computers.

So, the enumeration here is

$$15 \times 3 \times 2 = 90.$$


$\underline{3 + 2 + 1}$

There are $~\displaystyle \binom{6}{3} = 20~$ ways of selecting which $~3~$ computers will be grouped together, and then $~3~$ ways of determining which of the $~3~$ schools will receive these $~3~$ computers.

Then, there are $~\displaystyle \binom{3}{2} = 3~$ ways of selecting which $~2~$ of the remaining computers will be grouped together, and then $~2~$ ways of determining which of the $~2~$ remaining schools will receive these $~2~$ computers.

Then, there is only $~1~$ computer remaining, which must go to the $~1~$ remaining school.

So, the enumeration here is

$$20 \times 3 \times 3 \times 2 = 360.$$


$\underline{2 + 2 + 2}$

Avoiding over-counting here is tricky.

Assume that School-1 will receive whichever $~2~$ computers are the first $~2~$ selected.

Then, assume that School-2 will receive whichever $~2~$ computers are the next $~2~$ selected.

Then, assume that School-3 will receive whichever $~2~$ computers are the last $~2~$ selected.

There are $~\displaystyle \binom{6}{2} = 15 ~$ ways of selecting the $~2~$ computers that will go to School-1.

Then, there are $~\displaystyle \binom{4}{2} = 6 ~$ ways of selecting the $~2~$ computers that will go to School-2.

Then, the remaining $~2~$ computers must go to School-3.

So, the computation here is

$$15 \times 6 = 90$$


$\underline{\text{Final Computation}}$

$$90 + 360 + 90 = 540.$$

user2661923
  • 42,303
  • 3
  • 21
  • 46
2

I'm assuming the computers are distinguishable. As you note, without constraints there are $3^6=729$ ways to distribute $6$ computers to $3$ schools. We use the Principle of Inclusion and Exclusion to account for the constraints.

There are $2^6=64$ ways to distribute the computers so that School $n$ receives none for $n=1, 2, 3$. Therefore, we must subtract $3 \cdot 2^6=192$ "bad" combinations.

But this overcounts the "bad" combinations because when a combination violates two different constraints, it gets subtracted twice. There are $3$ ways to violate two different constraints -- distribute all $6$ computers to School $n$ for $n=1, 2, 3$.

Therefore, the total number of "good" combinations is $729-192+3=540$.

It's easy to see that your method overcounts. If each school gets exactly two computers, that combination is counted multiple times by your method.

Robert Shore
  • 26,056
  • 3
  • 21
  • 49