Tuesday, February 16, 2010

How will you measure?

You are given 2 containers one is of 5 liters capacity and other is 3 liters.
Measure 4 liters using the above two containers only.(You are given unlimited supply of water , containers are unmarked).


Start from the 5 liters can fill it and empty it in to 3 liters.
So now you have 2 liters in 5 liter can and 3 liters can is full.
Empty 3 liters can . And move 2 liters from 5 liter can to 3 liter can.
Now 3 liter can has 2 liters and 5 liter can is empty.
Now Again fill 5 liter can . Transfer as much as you can in 3 liters can.
Since you are left with only 1 liter volume in 3 liter can you can transfer only 1 liter into it.So you are left with 4 liters in 5 liters can now.

50-> 23 -> 20 -> 02 -> 52 -> 43.


Mathematically

5x+3y = 4
x = 2 y =-2 Therefore |x| + |y| = 4

i.e we need to find x and y values such that |x|+|y| is minimum.

So x here means take water 2 times from 5 liter can and drain out water from 3 liter can 2 times.

One more

There is an ample supply of milk in a milk tank. You have a 5-liter and a 9-liter cans, both of them unmarked. How can you measure out 2 liters?.

5X + 9Y = 2

X = 4 and Y = -2

50 -> 05 -> 55 -> 19 -> 10 -> 01 -> 51 -> 06 -> 56 -> 29.

done!!

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.