Two Bucket exercise: Error in tests

Unless there’s a constraint I’m misunderstanding, the test are logically wrong.

In Two Bucket the problem to solve is to find the number of steps needed to get a bucket to a certain amount; by filling, by emptying, and pouring from one bucket to other. The first step is always to fill a given bucket.

The first test is for buckets of size 3 and 5, target liquid 1, starting with the first bucket. The number of steps in the answer is 4.

The second test is for buckets of size 3 and 5, target liquid 1 (same as first test), starting with the second bucket (change from first test). The number of steps in the answer is 8.

However for the second case/test…

Surely you can fill bucket 2 (step 1), then empty bucket 2 (step 2) and act as if the first bucket was the starting one . If answer to that is 4, now we can solve it in 6 steps, not 8.

The same goes for test 3 and 4. In the general sense, if the other bucket yields n steps, you’re guaranteed a n+2 solution.

Nope. Starting with bucket 2 means actually starting with bucket 2 and proceeding in a fashion where you don’t “reset and start with the other bucket”.

@IsaacG is correct, the instructions specify that explicitly:
After an action, you may not arrive at a state where the starting bucket is empty and the other bucket is full.” (source)

and the other bucket is full

The other bucket isn’t full.

Following what you wrote above:
step 1: fill bucket two
step 2: empty bucket two (and then act as if the first bucket was the starting one)
step 3: fill bucket one
this is now an illegal state, the starting bucket is empty and the other bucket is full.

2 Likes

Sorry, you’re right, I focused on the 0 0 state.

1 Like