Question: Write a Java program called WaterJugs to determine the transfers required to reach the goal. The input is a single line containing four integers between

Write a Java program called WaterJugs to determine the transfers required to reach the goal. The input is a single line containing four integers between 2 and 100 (inclusive) representing c1, c2, c3, and d. The output is a minimal sequence of jug content, starting with the initial contents and ending with one of the jugs containing d liters. Each line of the output should consist of 3 integers separated by spaces. If no solution exists, then your program should produce no output.

Good test case: 10 5 3 4

For example, if the input is 20 5 3 4 then a valid output is

20 0 0

15 5 0

15 2 3

18 2 0

18 0 2

13 5 2

13 4 3

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!