Saturday, June 26, 2010

die hard 3 jug 5 jug problem

Question:
You have two jugs a 3 and 5 liter jug how do you get 4 liters in a jug.

Answer:
This is one of the more basic questions, but it still appears in job interviews. It is basically impossible not to get the answer correct.

1) First fill the 5 liter jug.
2) Poor water from the 5 liter into the 3 liter one until its full. That leaves 2 liters in the 5 liter,
3) Empty the 3 liter and transfer the 2 liters into it. This leaves 1 liter of space in the 3 liter jug.
4) Then fill the 5 liter jug
5) Then poor 1 liter out of the 5 liter into the 1 liter of empty space in the 3 liter jug.

Done the 5 liter jug has 4 liters in it

1 comment:

  1. Another way.
    1) Fill the 3 ltr jug, put it in 5 ltr jug.
    2) Again fill the 3 ltr jug, put it in 5 ltr jug till its full. Now 3 ltr jug has 1 ltr.
    3) Empty the 5 ltr jug.
    4) Put the 1 ltr from 3 ltr jug into 5 ltr jug.
    5) Fill up the 3 ltr jug and put it in 5 ltr jug again.

    ReplyDelete