The solution can be formulated as : x1+x2+x3+x4 = 12, which has solution 12+4-1C 4-1 = 455(Star and bar problem).
It will also include cases where x1 , x2 , x3 , x4 will take 10 , 11 , 12 values which cannot be the values of any digit.
So we have to remove all those cases.
Now, secondly when 1st digit becomes 0 then the number will not be of 4 digits. So we have to remove those cases.
In that case, put x1 = 0 and find the solution for x2+x3+x4 = 12 => 14C2 = 91(It will also remove all cases where x1 = 0 and x2,x3,x4 >= 0 )
Now we have to remove that case where x1 takes 10 , 11 , 12.
When x1 = 10, x2 +x3+x4 = 2 which gives 4C2 = 6.
When x1 = 11, x2+x3+x4 = 1 which gives 3C2 = 3.
When x1 = 12, x2+x3+x4 = 0 which gives 2C2 = 1.
Now, cases when x2,x3,x4 >= 10 we will count cases for x2 only , same will be applied on x3 and x4 also
x2 = 10 , x1 = 1 , then x3 + x4 = 1 which gives 2C1 = 2.
x2 = 10 , x1 = 2 , then x3 + x4 = 0 which gives 1C1 = 1.
x2 = 11 , x1 = 1 , then x3 + x4 = 0 which gives 1C1 =1.
total ways = 3 * ( 2 + 1 + 1 ) = 12 , same for x3 and x4.
Now total ways : 15C3 - 14C2 - ( 6 + 3 + 1 ) - 12 = 455 - 91 - 22 = 342.