Combinatorial way of sum of digits I just started my combinatorics course and I am having trouble with a few exercises.

How many numbers are there in the range $[3000, 8000]$ that the sum of their digits is 20?

I tried considering x1x2x3x4 as the number, and did $(n+k-1)$ choose $k$ as in $n=20$ and $k=4$ to choose the number whose $x_1+x_2+x_3+x_4 = 20$ but I have no idea on how to subtract the $x_1$'s who are less than $3$ or more than 8!

In how many ways can we select (given the alphabet of $26$ letters):

*

*A word with $7$ letters, where P appears exactly twice?


*A word with $8$ letters, where $P$ appears exactly $ 3$ more times than $X$?

For the first one, I calculated it in the old-fashioned way, where I choose first P to be first letter than did how many variations it could have. I have no idea on the second.
Sorry for putting 3 questions in one question, but I am really having a hard time with this course from the beginning!
 A: Work the first problem as five separate problems, one for each of the first digits $3,4,5,6$, and $7$. (There is clearly no such number with first digit $8$.) If the first digit is $3$, for instance, the remaining three digits must sum to $17$, so there are $\binom{17+3-1}{3-1}=\binom{19}2$ such numbers.
The second problem can be done more easily. There are $\binom72$ ways to choose two positions for the two $P$’s. The $5$ positions can each be filled with any of the other $25$ letters, so there are $25^5$ ways to fill them, and you get a grand total of $\binom7225^5$ words.
For the last problem suppose that you have $n$ $X$’s. Then you have $n+3$ $P$’s, and these two letters alone account for $2n+3$ letters. Since you have only $8$ spots available, $n$ must be $0,1,2$, or $3$. Solve each of the four cases separately, and add the results; the individual cases are handled much like the second problem, though you’ll have two binomial coefficients and a power.
A: With regard to #1, the question can be answered recursively.  A four digit number can have its digits add to 20 only if the left-most 3 digits add to 20, and the fourth is 0, or the left-most 3 digits add to 19, and the fourth is 1, or the left-most 3 digits add to 18, and the fourth is 2, and so on. 
If $N(num,total)$ is the number of num-digit numbers whose digits add to total, then$$N(j,k)=Num(j-1,k)+Num(j-1,k-1)+Num(j-1,k-2)+...+Num(j-1,k-9)$$subject, in this case, to$$N(1,3)=N(1,4)=N(1,5)=N(1,6)=N(1,7)=1$$and all other $N(1,k)=0$
