# Wrong test case

• How is x=1 y=2 and z=3 supposed to return false ?
That test case is failing my solution saying the answer is false, but clearly the answer for this input is true.

• I have the same confusion. Why cannot use two together?

• Same here. ridiculous , I have to change my code to 'satisfy' the answer

• can not agree more

• Found the same issue while running tests. Should state this clearly in the description if it's not allowed to split the z liters into two jugs.

Eventually I submitted something like this:

``````public boolean canMeasureWater(int x, int y, int z) {
if (z < 0) return false;
if (z == 0) return true;
// If at least one of the jugs were broken...
if (x <= 0) return y == z;
if (y <= 0) return x == z;
// If measuring z with both jugs were permitted...
//if (z > x + y) return false;
// If z must be fitted into one single jug...
if (z > (x > y ? x : y)) return false;
return z % gcd(x, y) == 0;
}``````

• Sorry for the introduced mistake. I have fixed it. Please try again, thanks.

• Now the testcase for x=1, y=1, z=12 expects false, but it should be true

• @bmaslakov How? The most you can get is x+y = 2

• @lufangjianle You can use a container with 1 twelve times

• you are supposed to contain 12L water, not get 12L water. The max capacity you can reach is x+y, there's no point to dumping all the water you've already contained.

• I see, sorry, I misread the question.

• You should make it clear in the question that at the end of the algorithm, you must have z liters of water contained within one or both buckets. Should clear up a lot of confusion.

• Thanks, I have just revised the problem description.

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.