First problem:
How many ways are there to distribute $26$ identical balls into six distinct boxes such that the number of balls in each box is odd?
Let $x_k$ denote the number of balls placed in the $k$th box, $1 \leq k \leq 6$. Then
$$x_1 + x_2 + x_3 + x_4 + x_5 + x_6 = 26 \tag{1}$$
Since each $x_k$ is a positive odd integer, $x_k = 2y_k + 1$ for some non-negative integer $y_k$. Substituting into equation 1 and simplifying yields
$$y_1 + y_2 + y_3 + y_4 + y_5 + y_6 = 10 \tag{2}$$
which is an equation in the non-negative integers. The number of solutions of equation 2 is the number of ways five addition signs can be inserted into a row of ten ones.
There are $$\binom{10 + 5}{5} = \binom{15}{5}$$ solutions since we must choose which five of the fifteen symbols (ten ones and five addition signs) will be addition signs.
Second problem:
How many ways are there to distribute $26$ identical balls into six distinct boxes such that the first three boxes contain at most six balls?
We wish to solve the equation
$$x_1 + x_2 + x_3 + x_4 + x_5 + x_6 = 26 \tag{3}$$
in the non-negative integers subject to the constraints that $x_1, x_2, x_3 \leq 6$. Equation 3 is an equation in the non-negative integers. It has
$$\binom{26 + 5}{5} = \binom{31}{5}$$
solutions.
We must exclude those cases in which one or more of the constraints is violated.
Suppose the constraint $x_1 \leq 6$ is violated. Then $x_1 \geq 7$. Let $y_1 = x_1 - 7$. Then $y_1$ is a non-negative integer. Substituting $y_1 + 7$ for $x_1$ in equation 3 and simplifying yields
$$y_1 + x_2 + x_3 + x_4 + x_5 + x_6 = 19 \tag{4}$$
Equation 4 is an equation in the non-negative integers. It has
$$\binom{19 + 5}{5} = \binom{24}{5}$$
solutions. By symmetry, equation 3 has the same number of solutions if the constraint $x_2 \leq 6$ or the constraint $x_3 \leq 6$ is violated. Hence, there are
$$\binom{3}{1}\binom{24}{5}$$
solutions in which one of the constraints is violated.
Suppose the constraints $x_1 \leq 6$ and $x_2 \leq 6$ are both violated. Let $y_1 = x_1 - 7$; let $y_2 = x_2 - 7$. Then $y_1$ and $y_2$ are non-negative integers. Substituting $y_1 + 7$ for $x_1$ and $y_2 + 7$ for $x_2$ and simplifying yields
$$y_1 + y_2 + x_3 + x_4 + x_5 + x_6 = 12 \tag{5}$$
which is an equation in the non-negative integers with
$$\binom{12 + 5}{5} = \binom{17}{5}$$
solutions. By symmetry, equation 3 has the same number of solutions if both the constraints $x_1 \leq 6$ and $x_3 \leq 6$ are violated or both the constraints $x_2 \leq 6$ or $x_3 \leq 6$ are violated. Hence, there are
$$\binom{3}{2}\binom{17}{5}$$
solutions in which two of the constraints are violated.
Suppose that all three constraints are violated. Let $y_k = x_k - 7$, $1 \leq k \leq 3$. Then each $y_k$ is a non-negative integer. Substituting $y_k + 7$ for $x_k$, $1 \leq k \leq 3$, and simplifying yields
$$y_1 + y_2 + y_3 + x_4 + x_5 + x_6 = 5 \tag{6}$$
which is an equation in the non-negative integers with
$$\binom{5 + 5}{5} = \binom{10}{5}$$
solutions.
By the Inclusion-Exclusion Principle, the number of ways the $26$ identical balls can be distributed into six distinct boxes such that the first three boxes contain at most six balls is
$$\binom{31}{5} - \binom{3}{1}\binom{24}{5} + \binom{3}{2}\binom{17}{5} - \binom{3}{3}\binom{10}{5}$$
I think this maybe what you are looking for...
a) Say each of the 6 children were to get one pencil each, then that can be done in only 1 way, since the pencils are all identical, it doesn't matter who gets which one, they are all the same.
or
b) Each of the six children get at-least one pencil.Then this is a stars and bars problem. It's like solving x1 + x2 + x3 + x4 + x5 + x6 = 20, but all xi take positive integer values > 0.Then the answer will be 20-1C6-1 ways.
or
c) It's possible that at-least one kid gets no pencil, which is the same as solving x1 + x2 + x3 + x4 + x5 + x6 = 20, but xi can also be 0 unlike in the previous case. Then this is 20+6-1C6-1 ways.
d) Now to answer, the probability question, like you said this is 1, because if each student gets a different number of pencils, starting with 1 pencil for the first student, 2 pencils for the second, 3 for the the third and so on...then, the least possible number of pencils such that each student gets a different no: of pencils, will be 21, since, 1+2+3+4+5+6 = 21. Therefore, at-least two students have to get the same number of pencils to make the total 20.
I guess we can write that as p(atleast two students getting same no of pencils) = 1 - p(everyone getting different no: of pencils) and
everyone getting different number of pencils will be => x1 + x2 + x3 + x4 + x5 + x6 = 20, such that, x1 ≠ x2 ≠ x3 ≠ x4 ≠ x5 ≠ x6, and xi >0.
Best Answer
As you observed, we can first distribute three pens to each of the four students, leaving $13$ additional pens to be distributed to the four students. The restriction that no student receive more than seven pens means that no student can receive more than four additional pens. Let $x_k$ be the number of additional pens received by the $k$th person. Then we must solve the equation $$x_1 + x_2 + x_3 + x_4 = 13 \tag{1}$$ in the non-negative integers subject to the restrictions that $x_k \leq 4$ for $1 \leq k \leq 4$. A particular solution of equation 1 in the non-negative integers is determined by where we place three addition signs in a row of thirteen ones. For instance, $$1 1 1 1 + 1 1 + 1 1 1 1 1 1 1 1 +$$ corresponds to the solution $x_1 = 4$, $x_2 = 2$, $x_3 = 8$, and $x_4 = 0$, while $$1 1 1 + 1 1 1 1 + 1 1 1 1 1 + 1$$ corresponds to the solution $x_1 = 3$, $x_2 = 4$, $x_3 = 5$, and $x_4 = 1$. The number of such solutions is equal to the number of ways we can select which three of the sixteen symbols (three addition signs and thirteen ones) will be addition signs, which is $$\binom{13 + 3}{3} = \binom{16}{3}$$ From these, we must subtract those solutions in which one or more of the variables exceeds $4$. Since $3 \cdot 5 = 15 > 13$, at most two two of the variables can exceed $4$.
Suppose $x_1 > 4$. Let $y_1 = x_1 - 5$. Then $y_1$ is a non-negative integer. Substituting $y_1 + 5$ for $x_1$ in equation 1 yields \begin{align*} y_1 + 5 + x_2 + x_3 + x_4 & = 13\\ y_1 + x_2 + x_3 + x_4 & = 8 \tag{2} \end{align*} Equation 2 is an equation in the non-negative integers. The number of solutions of equation 2 is the number of ways we can select which three of twelve symbols (three addition signs and eight ones) will be addition signs, which is $$\binom{8 + 3}{3} = \binom{11}{3}$$ Since there are four ways one of the variables could exceed four, there are $$\binom{4}{1}\binom{11}{3}$$ ways of distributing more than four pens to at least one person.
Suppose $x_1 > 4$ and $x_2 > 4$. Let $y_1 = x_1 - 5$; let $y_2 = x_2 - 5$. Substituting $y_1 + 5$ for $x_1$ and $y_2 + 5$ for $x_2$ in equation 1 yields \begin{align*} y_1 + 5 + y_2 + 5 + x_3 + x_4 & = 13\\ y_1 + y_2 + x_3 + x_4 & = 3 \tag{3} \end{align*} Equation 3 is an equation in the non-negative integers with $$\binom{3 + 3}{3} = \binom{6}{3}$$ solutions. Since there are $\binom{4}{2}$ ways two of the four variables could exceed four, there are $$\binom{4}{2}\binom{6}{3}$$ distributions of pens in which at least two people receive more than four pens.
By the Inclusion-Exclusion Principle, the number of ways we can distribute $25$ pens to four people so that each person receives at least three and at most seven pens is $$\binom{16}{3} - \binom{4}{1}\binom{11}{3} + \binom{4}{2}\binom{6}{3}$$
Alternate Solution: A more efficient method than using the Inclusion-Exclusion Principle to solve equation 1 subject to the restrictions $x_k \leq 4$ for $1 \leq k \leq 4$ is to let $z_k = 4 - x_k$ for $1 \leq k \leq 4$. Then $0 \leq z_k \leq 4$ for $1 \leq k \leq 4$. Substituting $4 - z_k$ for $x_k$, $1 \leq k \leq 4$, in equation 1 yields \begin{align*} 4 - z_1 + 4 - z_2 + 4 - z_3 + 4 - z_4 & = 13\\ -z_1 - z_2 - z_3 - z_4 & = -3\\ z_1 + z_2 + z_3 + z_4 & = 3 \tag{4} \end{align*} Equation 4 is an equation in the non-negative integers with $$\binom{6}{3}$$ solutions.