# I have 3 cans of sizes 7, 9 and 16 liters resp. What is the minimum number of operations required to deliver 1 liter?

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.

• Use a triangular plot as described here. Oct 19, 2020 at 19:21

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:

$$16x+9y+7z=1$$

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 :

$$16x+9y+7z=1$$

$$(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:

$$S=|x|+|y|+|z|$$

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$$