This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
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?
(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.