Number of possible $7$-digit PIN codes What is the number of all possible $7$-digit PIN codes if 
1) all the digits in a code should be different? 
2) all the digits should be different and the first digit should be greater than the second one? 
3) the sum of the digits should be $9$? (digits may repeat)
I think the answer for the first question is $604800$
 A: For question 3, we can think of any $7$-digit number whose digits sum to $9$, for example $4011021$, as:
$$****||*|*||**|*$$
with each digit converted to that number of stars (possibly no stars!); and each digit separated by bars.
So we are counting the number of ways of choosing 7-1 = 6 bars from 6+9 positions. That value is
$${15 \choose 9} = 5005$$. 
A: HSE-ICEF, 1st course, 3rd Home Assignment? 


*

*1) $604800$

*2) $302400$

*3) $5005$


But, probably, it's too late.
A: The third one consists of the ordered partitions of $9$ into at most $7$ parts when taken over $7$ digits.
The partitions of $9$ that qualify are therefore $$9,\\81,\\72,711,\\63,621,6111,\\54,531,522,5211,51111,\\441,432,4311,4221,42111,411111,\\333,3321,33111,3222,32211,321111,3111111,\\22221,222111,2211111$$
Each one is calculated by taking the multinomial $\dbinom{7}{k_i}$ where each $k_i$ is the number of elements in each distinct digit group (not forgetting the zero digits), so, for example, for $4311$ becomes $\dbinom{7}{1,1,2,3}=\dbinom{7!}{1!1!2!3!}=7\cdot 5\cdot 4\cdot 3=420$.
