Trouble finding all positive solutions on linear diophantine equations with 3 variables I'm having trouble calculating all possible solutions for a system of 2 diophantine equations with 3 variables.
The question is:
Find all the positive solutions in integers of 
$$x  + y + z = 31$$
$$x+2y+3z=41$$
I substituted x in the second equation giving me 
$$x=31-y-z$$
$$31-y-z+2y+3z=41$$
Which gives me the equation:
$$y+2z=10$$
One solution would be $x=2, z=4$. Since I want only positive solutions I have the following inequalities
$$2+2t>0$$ 
and 
$$4-t>0$$
From that:
$$t>1$$ and $$4>t$$
So $4>t>1$. Since I only want integer answers, $t=3$ and $t=2$.
Substituting in the formula I get $$x=23, y=6, z=2$$ and $$x=22, y=8, z=1$$ which are both correct. 
However, in the book there are two other answers, $$x=24, y=4, z=3$$ and $$x=25, y=2, z=3$$
My question is, how do I arrive at those two other answers?
 A: Note that since $y>0$, $2z<y+2z=10$, then $0<z<5$. If $z=1$ we get $y=8$. If $z=2$ we get $y=6$. If $z=3$ we get $y=4$, and if $z=4$ we get $y=2$. Therefore we get the pairs $(y,z)=(8,1), (6,2), (4,3), (2,4)$. Using that $x=31-(y+z)$, you can get the values of $x$. 
A: iF $y+2z=10\implies y=10-2z\implies0<z<5$
A: The problem of enumerating absolutely all nonnegative integer solutions of a linear Diophantine equation of any dimensionality was solved by Voinov, V. and Nikulin, M.  in Voinov and Nikulin (1997) On a subset sum algorithm and its probabilistic and other applications. Balakrishnan N, ed. {\ it Advances in Combinatorial Methods and Applicatinions to Probability and Statistics}. - Boston: Birkh\"{a}auser, 1997. PP. 153-163. Currently, to solve this problem, you may use the R-package "nilde" from CRAN as follows:
1) library(nilde)
b5<-nlde(a=c(1,1,1),n=31,at.most=T)
b5
b6<-nlde(a=c(1,2,3),n=41,at.most=T)
b6
colSums(b6$solutions*c(1,1,1))
Having performed this you'll get all 6 solutions of your problem:
{21,10,0}, {22,8,1}, {23,6,2}, {24,4,3}, {25,2,4}, and {26,0,5}.
I hope that you and everybody other will understand that actually
all problems of discrete optimization are reduced to the anumeration of all nonnegative integer solutions of a linear Diophantine equation solved in Voinov and Nikulin (1997) On a subset sum algorithm and its probabilistic and other applications. Balakrishnan N, ed. {\ it Advances in Combinatorial Methods and Applicatinions to Probability and Statistics}. - Boston: Birkh\"{a}auser, 1997. PP. 153-163.  
