6
$\begingroup$

This question already has an answer here:

I have gone through simple water jug problems like this link but when there are 3 jugs:

  • 16 Galoon jug with water filled.
  • 11 Galoon empty jug.
  • 6 Galoon empty jug.

Find a solution to gain 8 Galoon, using these 3 jugs.

$\endgroup$

marked as duplicate by A E, DrunkWolf, Deusovi, AJL, manshu Jan 30 '16 at 15:22

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

7
$\begingroup$

Assuming you may dispose of water...

Call the jugs A, B, C respectively.

  • fill C from A. (10,0,6)
  • empty C into B. (10,6,0)
  • fill C from A. (4,6,6)
  • fill B from C. (4,11,1)
  • pour out the litre from C (4,11,0)
  • empty B into A. (15,0,0)
  • fill C from A (9,0,6)
  • empty C into B (9,6,0)
  • fill C from A. (3,6,6)
  • fill B from C. (3,11,1)
  • pour out the litre from C (3,11,0)
  • empty B into A (14,0,0)
  • fill C from A (8,0,6)

Jug A now has 8 litres.

If we may not discard water:

  • A to C (10,0,6)
  • A to B (0,10,6)
  • C to A (6,10,0)
  • B to C (6,4,6)
  • C to A (12,4,0)
  • B to C (12,0,4)
  • A to B (1,11,4)
  • B to C (1,9,6)
  • C to A (7,9,0)
  • B to C (7,3,6)
  • C to A (13,3,0)
  • B to C (13,0,3)
  • A to B (2,11,3)
  • B to C (2,8,6)

Jug B now has 8 litres.

$\endgroup$
  • $\begingroup$ Darn it. Late by a minute. Well done @frodoskywalker. $\endgroup$ – CodeNewbie Jun 19 '15 at 9:52
  • $\begingroup$ also late by a min $\endgroup$ – Wouter Jun 19 '15 at 9:53
  • $\begingroup$ can not dispose the water :( $\endgroup$ – KRU Jun 19 '15 at 10:03
  • $\begingroup$ @KRU that's fine, I've added a method which doesn't need you to dispose of water. $\endgroup$ – frodoskywalker Jun 19 '15 at 10:19
1
$\begingroup$

Another way of producing same result with minimum steps would be as below:

Lets assume 16 Litre jug as A, 11 Litre jug as B and 6 Litre jug as C.

Initial Configuration : (16 0 0)

  1. A to C (10 0 6).
  2. C to B (10 6 0).
  3. A to C ( 4 6 6).
  4. C to B (4 11 1).
  5. B to A (15 0 1).
  6. C to B (15 1 0).
  7. A to C (9 1 6).
  8. C to B (9 7 0).
  9. A to C (3 7 6).
  10. C to B (3 11 2).
  11. B to A (14 0 2).
  12. C to B (14 2 0).
  13. A to C (8 2 6).
$\endgroup$

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