I was reading about elementary number theory when I came across this question. I've seen such questions before but never found any systemic approach on how to solve them. Does there exist one? Please elaborate since I'm just a beginner.

  • 2
    $\begingroup$ Use a triangular plot as described here. $\endgroup$
    – Jean Marie
    Oct 19, 2020 at 19:21

1 Answer 1


Considering the reference given by Jean Marie in comment, for a mathematical model let x, y and z be the numbers of filing of 16, 9 and 7 liter cans respectively. If x or y or z is positive it means you fill the can, if each of them is negative it means the related can is filled by another can. Now we construct a linear Diophantine equation with three unknown x, y and z as below:


Thus equation gives the number of filling of each can from the tank (filling) and transitions(from a can to another can). $1$ on the RHS is the result of algebraic sum of terms and gives the volume of liquid finally remains in a can which you want to be one liter. Meanwhile you want the sum of operation $S=x+y+z$ be minimum. We solve above equations and take small values :


$(x, y, z)=(5, -8, -1),(6, -9, -2), (-2, -1, 6), (-1, -2, 5), (-1, 5, -4), (-2, 6, -3)$

The sum of operation is:


So the related sums of above results are:

$S=14, 17, 9, 8, 10, 11$

Hence minimum operations is $8$ which results from $(x, y, z)=(-1, -2, 5)$

Which suggests following operations:

Five times filling the 7 Liter can from the tank. One time Pouring in 16 Liter can and two times in 9 Liter can to fill them by filled 7 Liter can ; what finally remains in 7 Liter can is:

$5\times 7-1\times 16-2\times 9=1$


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .