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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started