Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!

# Sharing the peanut oil

Rakesh Joshi
Ranch Hand
Posts: 218
Mary has a full 8-quart container (Container A) of peanut oil. She wants to share half of the oil with her sister. She has another 2 empty containers (B and C) with the capacities: 5 quarts and 3 quarts. Can you, without weighing the containers, put 4 quarts of oil in container B with the least number of steps for her sister?

Manish Hatwalne
Ranch Hand
Posts: 2596
One quick solution -

(1) Take out 3 quarts of oil from A into C. A has 5 quarts left now.
(2) Transfer 3 quarts from C to B. Now B has 3, A has 5 and C has zero.
(3) Take out Another 3 quarts from A into C. A=2, B=3, and C=3 now.
(4) Transfer from C to B only till B is full. A=2, B=5 and C=1 ((3-2)) now.
(5) Empty B in A now. A=7, B=0 and C=1;
(6) Put C in B. A=7, B=1 and C=0;
(7) Take out 3 quarts from A to C. A=4, B=1 and C=3.
(8) Transfer C to B. A=4, B=4 and C=0.

Done! Shorter maybe.....

- Manish
[ March 24, 2006: Message edited by: Manish Hatwalne ]

Shaan Shar
Ranch Hand
Posts: 1249
Dear Hat Waale/ Joshi.

Yes Thats right. Now this question should be closed. Rakesh do you have any query regarding this question. Please ask to Hat Waale. otherwise give your confirmation.

Manish Hatwalne
Ranch Hand
Posts: 2596
Originally posted by Ankur Sharma:
Dear Hat Waale/ Joshi.

Yes Thats right. Now this question should be closed. Rakesh do you have any query regarding this question. Please ask to Hat Waale. otherwise give your confirmation.

Ankur,

I have a proper name - Manish. Please use that and do not make fun of my surname, though you may not have inteded it that way.

- Manish

Ray Stojonic
Ranch Hand
Posts: 326
0- A8 B0 C0
1- A3>B5 C0
2- A3 B2>C3
3- A6<B2-C0
4- A6 B0>C2
5- A1>B5 C2
6- A1 B4>C3

Zip Ped
Ranch Hand
Posts: 336
See Die Hard with a Vengeance..the answer is in there. This is an AI question.

Shaan Shar
Ranch Hand
Posts: 1249
Ankur,

I have a proper name - Manish. Please use that and do not make fun of my surname, though you may not have inteded it that way.

- Manish
---

Manish I am really sorry for that, if you hurt but beleive me that was not intended that was totally a typo mistake........ pls don't get hurt... I extremly apolozise for this typo mistake.........

I hope now onwards you don't have any wrong spirit for me...