# Thread: Pour me another one

1. ## Pour me another one

You got a 4gallon and a 9gallon container, an unmarked container, and a huge water supply.

You want to end up with exactly 6 gallons in the unmarked container.
YES: the unmarked container > 6 gallons!

You mission is to do it in exactly 9 moves, and using the MINIMUM
number of gallons of water from the water supply.

A "move" is any pouring and/or filling; as example, filling the
9gal from the water supply, then pouring to fill the 4gal container,
then emptying it out is 3 moves: fill-pour-empty.

How do you do it?

2. I shall refer to the 9 gallon, 4 gallon, and unmarked container as A, B, and C respectively. When I say A = 4, it means there are 4 gallons of water in container A.

1. Fill A
A = 9 B = 0 C = 0

2. Pour water from A to B until B is full
A = 5 B = 4 C = 0

3. Pour the remaining water from A into C.
A = 0 B = 4 C = 5

4. Pour water from B into A
A = 4 B = 0 C = 5

5. Pour water from C into B until B is full
A = 4 B = 4 C =1

6. Empty B
A = 4 B = 0 C = 1

7. Top up the water in A
A = 9 B = 0 C = 1

8. Pour water from A to B until B is full
A = 5 B = 4 C = 1

9. Pour the remaining water from A to C
A = 0 B = 4 C = 6

Total gallons of water used =
9 + 5 = 14

I made that up along the way, but I'm not sure if it used the minimum number of water.

3. Hello, Wilmer!

I think I got it . . .

You have a 4-gallon and a 9-gallon container, an unmarked container, and a huge water supply.

You want to end up with exactly 6 gallons in the unmarked container.
(YES: the unmarked container > 6 gallons!)

Your mission is to do it in exactly 9 moves, and using the MINIMUM number of gallons of water
from the water supply.

A "move" is any pouring, filling or emptying.
For example, filling the 9-gal from the water supply,
then pouring it to fill the 4-gal container,
then emptying it is 3 moves: fill - pour - empty.

How do you do it?
Spoiler:

(1) Fill the "9".

Code:
                  *     *
|/////|
|/////|     *     *
|/////|     |     |
|/////|     |     |
*     *     |//9//|     |  0  |
|     |     |/////|     |     |
|  0  |     |/////|     |     |
*-----*     *-----*     *-----*
4           9           U

(2) Pour "9" into "4".

Code:
                  *     *
|     |
|     |     *     *
|     |     |     |
|/////|     |     |
*     *     |/////|     |  0  |
|/////|     |//5//|     |     |
|//4//|     |/////|     |     |
*-----*     *-----*     *-----*
4           9           U

(3) Empty "4",

Code:
                  *     *
|     |
|     |     *     *
|     |     |     |
|/////|     |     |
*     *     |/////|     |  0  |
|     |     |//5//|     |     |
|  0  |     |/////|     |     |
*-----*     *-----*     *-----*
4           9           U

(4) Pour "9" into "4".

Code:
                  *     *
|     |
|     |     *     *
|     |     |     |
|     |     |     |
*     *     |     |     |  0  |
|/////|     |     |     |     |
|//4//|     |//1//|     |     |
* - - *     * - - *     * - - *
4           9           U

(5) Pour "9" into "U".

Code:
                  *     *
|     |
|     |     *     *
|     |     |     |
|     |     |     |
*     *     |     |     |     |
|/////|     |  0  |     |     |
|//4//|     |     |     |//1//|
*-----*     *-----*     * - - *
4           9           U

(6) Empty "4".

Code:
                  *     *
|     |
|     |     *     *
|     |     |     |
|     |     |     |
*     *     |     |     |     |
|     |     |  0  |     |     |
|  0  |     |     |     |//1//|
*-----*     *-----*     *-----*
4           9           U

(7) Fill "9".

Code:
                  *     *
|/////|
|/////|     *     *
|/////|     |     |
|/////|     |     |
*     *     |//9//|     |     |
|     |     |/////|     |     |
|  0  |     |/////|     |//1//|
*-----*     *-----*     *-----*
4           9           U

(8) Pour "9" into "4".

Code:
                  *     *
|     |
|     |     *     *
|     |     |     |
|/////|     |     |
*     *     |/////|     |     |
|/////|     |//5//|     |     |
|//4//|     |/////|     |//1//|
*-----*     *-----*     *-----*
4           9           U

(9) Pour "9" into "U".

Code:
                  *     *
|     |
|     |     *     *
|     |     |     |
|     |     |/////|
*     *     |     |     |/////|
|/////|     |  0  |     |//6//|
|//4//|     |     |     |/////|
*-----*     *-----*     *-----*
4           9           U

. . ta-DAA!

I used 18 gallons from the water supply
. . and discarded 8 gallons.
But I don't know if that's the optimal solution.

Edit: Gusbob, brilliant solution!
. . . You beat me by four gallons!
. . . Nice work!
.

4. Originally Posted by Gusbob
5. Pour water from C into B until B is full
A = 4 B = 4 C =1

6. Empty B
A = 4 B = 0 C = 1

7. Top up the water in A
A = 9 B = 0 C = 1
Good stuff....BUT only 10 gallons need be taken from supply:
At step#6, empty B into A: then you only need 1 gallon to fill A.

5. I'm assuming the 9 steps have to be defined and have meaning? So you don't pour into one barrel, then pour back, and repeat this to fill up a few steps? Because if such redundancy were permitted, this could be solved losing 6 gallons.

6. ## Re: Pour me another one

Total gallons of water used = 9 + 5 = 14

Hahaha very good answer, how did you get that so easily the question?

_________________________________
I love numbers