# Number of ways to distribute 20 identical pencils to 6 non-identical children with restrictions

How many ways are there to pass out 20 pencils (assume all the pencils are identical the same) to six children?

Based on the following condition:

a) No restriction. ( i.e. each kid may receive zero to 20 pencils.)

b) Every child receives at least one pencil.

c) None of child receives the same number of pencils.

d) If the pencils are given out randomly. What is the probability that there are at least two kids receive the same number of pencils if every kids receives at least one pencil?

I have calculated a) using C(25,20) = 53,130

I calculated b) using C(19,14) = 11,628

for c) I get answer 840 using the following program

class final34{
public static void main(String[] args){
int u,v,x,y,z;
int count = 0;
int last=0;

for(u =1;u<11;u++){
for(v = 1;v<11; v++)
if(u!=v)
for(x = 1;x<11;x++)
if(x!=u && x!=v)
for(y = 1; y<11;y++)
if(y!=u && y!=v && y!=x)
for(z=1;z<11;z++)
if(z!=u && z!=v && z!=x && z!=y)
if(u+v+x+y+z == 20){
System.out.println(u+" "+v+" "+x+" "+y+" "+z);
count++;
}
System.out.println("Count after iteration "+u+": "+(count-last));
last = count;
}
System.out.println("Total Count: "+count);
}
}


I see the output:

Count after iteration 1: 144

Count after iteration 2: 144

Count after iteration 3: 120

Count after iteration 4: 120

Count after iteration 5: 96

Count after iteration 6: 72

Count after iteration 7: 48

Count after iteration 8: 48

Count after iteration 9: 24

Count after iteration 10: 24

Total Count: 840

But I don't know how to prove this using discrete mathematics.

Also I need help on d).

a) and b) are correctly calculated.

d) If they all get the different number of pencils, then there would be at least $$1+2+3+4+5+6=21$$ pencils wich is impossibile.

So the probability that at least two will get the same number of pencil is $$1$$.

• Every one gets at least one pencil. – Aqua Mar 18 at 21:34
• Have you read what I wrote? – Aqua Mar 18 at 21:45
• can u please elaborate more? and give one or two examples of cases. I can not understand properly. – Abhishek Panjabi Mar 18 at 21:48
• It is impossibile to everone get differnt number of pencils if each gets at least one pencil. So the probability that at least two will get the same number of pencils is 100% – Aqua Mar 18 at 21:51
• Thank you. That helped. – Abhishek Panjabi Mar 18 at 21:52

I realized that there is no way to generalize the answer for question c). it needs a special solution.

First of all, out of 6 children, 1 child has to get 0 pencils. After that 5 children are remaining. So, there are just 7 ways to distribute 20 pencils among them, which are:

(1,2,3,4,10)

(1,2,3,5,9)

(1,2,3,6,8)

(1,2,4,5,8)

(1,2,4,6,7)

(1,3,4,5,7)

(2,3,4,5,6)

Now, with these 7 cases, there are 5! ways to arrange them in order.

Therefore, we get 120*7 = 840 ways.

Now, coming back to the first child, to whom we gave 0 pencils. It can be any of the 6 children.

So, 840*6 = 5040 is the final answer.

I could found the first 5 cases by myself, but, as anyone can see that the last two cases are too far and so many cases need to be checked before one can figure those two out. that's why I used a program to compute these. I am also providing that here so that it is helpful for others.

import java.util.*;

class final34{
public static void main(String[] args){
int u,v,x,y,z;
int count = 0;
int last=0;
List<List<Integer>> val = new ArrayList<List<Integer>>();

for(u =1;u<11;u++){
for(v = 1;v<11; v++)
if(u!=v)
for(x = 1;x<11;x++)
if(x!=u && x!=v)
for(y = 1; y<11;y++)
if(y!=u && y!=v && y!=x)
for(z=1;z<11;z++)
if(z!=u && z!=v && z!=x && z!=y)
if(u+v+x+y+z == 20){
List<Integer> temp = new ArrayList<>();
Collections.sort(temp);
boolean check = false;
for(List a: val){
Collections.sort(a);
if(a.equals(temp)){
check = true;
}
}
if(!check){