6
$\begingroup$

You have two 4 liter jugs and one 5 liter jug. All of them are empty.

You can fill up a jug to its full capacity, empty it or pour one jug into another one until the jug you pour into is full or the jug you pour from is empty.

Find the shortest sequence of filling, emptying and pouring that results in 2 liters in both 4 liter jugs.

$\endgroup$
6
$\begingroup$

12 steps:
5 0 0 - fill 5
1 4 0 - fill 4A from 5
0 4 1 - empty 5 into 4B
4 0 1 - empty 4A into 5
4 4 1 - fill 4A
5 3 1 - fill 5 from 4A
2 3 4 - fill 4B from 5
2 3 0 - empty 4B
0 3 2 - empty 5 into 4B
3 0 2 - empty 4A into 5
3 4 2 - fill 4A
5 2 2 - fill 5 from 4A

| improve this answer | |
$\endgroup$
2
$\begingroup$

My solution:

I will call the jugs 5 (5l), 4A (4l) and 4B (4l)
Fill 5, then use it to fill 4A. Empty 4A, then put in the remaining 1l from 5.
Fill 5, then use it to fill 4A. Empty 4A, then put in the remaining 2l from 5.
Repeat, for 4B.

| improve this answer | |
$\endgroup$
  • $\begingroup$ I am sorry, I missed my requirement to find the shortest sequence. I added it to the OP. While your solution is solving the problem, there is a way to get there in less steps. $\endgroup$ – Tweakimp Apr 18 at 17:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.