Skip to content
Related Articles
Get the best out of our app
GFG App
Open App
geeksforgeeks
Browser
Continue

Related Articles

Puzzle | Distribute the Water

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

Problem Statement: Suppose there are three containers; container I (3L), container II (5L), container III (8L). Container III is filled with 8L of water while the other two are empty. With the help of these 3 containers, how to distribute the water in equal volumes i.e. 4L in container II and, 4L in container III. Consider there is no loss of water when transferring it from one container to another.

Solution:
When there is no loss of water while transferring it from one container to another container. The only way to do the required task is to repeatedly transfer water from one container to another until one arrives at a favorable result. 

Step 1: Fill the 8L container full.

Step 2: Pour water from an 8L to 3L container. Water in the 8L container is now 5L and the 3L container is now full.

Step 3: Pour water from 3L container to 5L container. Water in the 5L container is now 3L and the 3L container is now empty.

Step 4: Pour water from 8L container to 3L container. Water now in the 8L container is 2L and the 3L container is full.

Step 5: Pour water from a 3L to 5L container. The 5L container is now full and the water in the 3L container is now 1L.

Step 6: Pour water from 5L container to 8L container. The water in the 8L container is now 7L and the 5L container is now empty.

Step 7: Pour water from the 3L container into the 5L container. The 3L container is now empty and the water in the 5L container is 1L.

Step 8: Pour water from the 8L container into the 3L container. The water in the 3L container is now 3L and the water in the 8L container is 4L.

Step 9: Pour water from the 3L container into the 5L container. The 3L container is now empty and the water in the 5L container is now 4L.

Below is the table that summarizes the above solution:

Step

Container I

Container II

Container III

1

0

0

8

2

3

0

5

3

0

3

5

4

3

3

2

5

1

5

2

6

1

0

7

7

0

1

7

8

3

1

4

9

0

4

4

My Personal Notes arrow_drop_up
Last Updated : 18 Jan, 2023
Like Article
Save Article
Similar Reads