How to find all the solutions to $a+2b+3c+\cdots+9i=45$ I want to find all the solutions to the equation $a+2b+3c+4d+5e+6f+7g+8h+9i=45$ where all of the variables can only be of $3$ values: $0,1,2$
I know there are a few solutions for example, set all of them to be $1$, or $a=1, b=2, c=0, d=1, e=0, f=2, g=1, h=1, i=1$.
I tried to turn them all into mod $3$ and I got:
$a+2b+d+2e+g+2h\equiv 0 \pmod 3$ but I don't know what to do after that.
I understand that there may be ~$7\times 10^{20}$ solutions

As @robjohn mentioned , you can find the number of all solutions using generating functions. If the possible values for the variables are $0,1,2$ ,we can say that

*

*$a:0,1,2$ . Hence , its generating function is $$x^0+x^1+x^2 = \frac{1-x^3}{1-x}$$


*If "b" can take the values of $0,1,2$ , then $2b:0,1,4$ . Hence , its generating function is $$x^0+x^2+x^4 = \frac{1-x^6}{1-x^2}$$


*If "c" can take the values of $0,1,2$ , then $3c:0,3,6$ . Hence , its generating function is $$x^0+x^3+x^6 = \frac{1-x^9}{1-x^3}$$


*If "d" can take the values of $0,1,2$ , then $4d:0,4,8$ . Hence , its generating function is $$x^0+x^4+x^8 = \frac{1-x^{12}}{1-x^4}$$


*If "e" can take the values of $0,1,2$ , then $5e:0,5,10$ . Hence , its generating function is $$x^0+x^5+x^{10} = \frac{1-x^{15}}{1-x^5}$$


*If "f" can take the values of $0,1,2$ , then $6f:0,6,12$ . Hence , its generating function is $$x^0+x^6+x^{12} = \frac{1-x^{18}}{1-x^6}$$


*If "g" can take the values of $0,1,2$ , then $7g:0,7,14$ . Hence , its generating function is $$x^0+x^7+x^{14} = \frac{1-x^{21}}{1-x^7}$$


*If "h" can take the values of $0,1,2$ , then $8h:0,8,16$ . Hence , its generating function is $$x^0+x^8+x^{16} = \frac{1-x^{24}}{1-x^8}$$


*If "i" can take the values of $0,1,2$ , then $9i:0,9,18$ . Hence , its generating function is $$x^0+x^9+x^{18} = \frac{1-x^{27}}{1-x^9}$$
Now , find the coefficient of $x^{45}$ in the expansion of $$\bigg(\frac{1-x^{3}}{1-x}\bigg)\bigg(\frac{1-x^{6}}{1-x^2}\bigg)\bigg(\frac{1-x^{9}}{1-x^3}\bigg)\bigg(\frac{1-x^{12}}{1-x^4}\bigg)\bigg(\frac{1-x^{15}}{1-x^5}\bigg)\bigg(\frac{1-x^{18}}{1-x^6}\bigg)\bigg(\frac{1-x^{21}}{1-x^7}\bigg)\bigg(\frac{1-x^{24}}{1-x^8}\bigg)\bigg(\frac{1-x^{27}}{1-x^9}\bigg)$$
NOTE: You can use sofwares such as SageMath to find the coefficent of $x^{45}$ in the expansion , i generally use wolfram alpha but this expansion was long for wolfram
