We are here with a question that is asked especially in software-related job interviews and tests your algorithmic thinking. With this logic question, you can find out if you have an algorithmic intelligence.
This question, which asks you to measure with two buckets, is frequently encountered by interviewers in fields such as software engineers. Then come to the question:
You have two buckets, one with a capacity of 3 and the other with a capacity of 5 liters. You can fill and empty these buckets with water.
You can completely fill or empty a container. You can also use the water in one container to fill the other container. The question is: Can you get 4 liters of water by filling and emptying these two buckets?
Let’s give you some time to solve the problem.
So let’s get to the answer now.
First of all, this is an algorithm question, so we can get the right result in different ways. We will tell you how to reach 4 liters of water in two different ways. While doing this, we will explain it in an algorithmic system, that is, step by step.
To reach 4 liters of water from a slightly longer route:
- Fill a 3 liter bucket with water.
- Pour this filled water into the 5-liter bucket. The 5 liter bucket now contains 3 liters of water.
- Refill the 3 liter bucket.
- Pour this water into the 5 liter bucket until the bucket is full. Now you have 1 liter of water left in the 3 liter bucket.
- Pour the water completely in the 5 liter bucket.
- Pour the remaining 1 liter of water from the 3 liter bucket into the 5 liter bucket.
- Refill the 3 liter bucket.
- Pour the water from the 3 liter bucket into the 5 liter bucket. You have 4 liters of water left.
Now let’s see how to get 4 liters of water with fewer steps.
- Fill the 5 liter bucket with water.
- Pour this water into the 3-liter bucket until it is full. There are 2 liters of water left in the 5 liter bucket.
- Empty the 3 liter bucket.
- Pour the 2 liters of water from the 5 liter bucket into the 3 liter bucket.
- Fill the 5 liter bucket completely.
- Pour the 5 liter bucket into the 3 liter bucket until it is full. You have 4 liters of water left.
So in how many steps did you find the answer? If you found the answer to your question in a different step, you can write to us in the comments.
Sources: Stack Exchange, Careercup