Number of all possible ways to select numbers a_i such that they sum to n subject to the condition that (m_i)<= (a_i) <= (k_i) is equal to the number of non-negative integral soutions of
[i=1]
[p] a_i =n$, where each a_i is distinct and subject to the above conditions.
The total number of such solutions is equal to the coefficient of x^n in the expansion of
(x^{m_1}+x^{m_1+1}+.........+x^{k_1}) * (x^{m_2}+x^{m_2+1}+....+x^{k_2}).......(x^{m_p}+x^{m_p+1}+....+x^{k_p})
This is also called the multinomial theorem.
In the above problem we need to find all numbers such that the sum of digits is 18. So it is equal to the number of solutions to a+b+c+d+e+f=18, where a is the 100000 place digit, b is the 10000 place digit and so on.....
I did a mistake in the previous solution (did not think and write) and the mistake was that even the 100000 digit can be zero and yet , there will be no overcounting.
Hence the correct answer will be equal to the coefficient of x^{18} in the expansion of (1+x+x^2+....+x^9)^6