Consider the following problem: 1. You have a four-gallon jug and a three-gallon jug, neither of which has any markings. Understand what this means. The only reliable observations are: a jug is empty in which case it has zero gallons in it; or, a jug is full, in which case it has its "capacity" gallons in it, and any other conclusions you can logically draw from these states. For example, say you fill the 4-gallon jug, and then fill the 3-gallon jug from it, you can logically conclude that there is 1 gallon left in the 4-gallon jug. Since the jugs have no markings, no other amounts can be transferred from the full 4- gallon jug to the 3-gallon jug. In this example, you cannot transfer 1, or 1.5, or 2, or 2.25, or 3.142 gallons of water from the 4- gallon jug to the 3-gallon jug. 2. There is a faucet from which you can top off the jugs as many times as you wish. Following this, a jug has its "capacity" gallons in it. 3. You can empty one jug into the other, or onto the ground, in which case the jug is known to have zero gallons in it. 4. You can transfer water between the two jugs. Again, since the jugs have no markings, the only transfers that are logical are those that leave one jug full or the other empty. Write a Prolog program that finds a sequence of moves (in the form of a list of instructions) that, starting from two empty jugs, ends with exactly two gallons of water in the 4-gallon jug and no water in the 3-gallon jug.
Consider the following problem: 1. You have a four-gallon jug and a three-gallon jug, neither of which has any markings. Understand what this means. The only reliable observations are: a jug is empty in which case it has zero gallons in it; or, a jug is full, in which case it has its "capacity" gallons in it, and any other conclusions you can logically draw from these states. For example, say you fill the 4-gallon jug, and then fill the 3-gallon jug from it, you can logically conclude that there is 1 gallon left in the 4-gallon jug. Since the jugs have no markings, no other amounts can be transferred from the full 4- gallon jug to the 3-gallon jug. In this example, you cannot transfer 1, or 1.5, or 2, or 2.25, or 3.142 gallons of water from the 4- gallon jug to the 3-gallon jug. 2. There is a faucet from which you can top off the jugs as many times as you wish. Following this, a jug has its "capacity" gallons in it. 3. You can empty one jug into the other, or onto the ground, in which case the jug is known to have zero gallons in it. 4. You can transfer water between the two jugs. Again, since the jugs have no markings, the only transfers that are logical are those that leave one jug full or the other empty. Write a Prolog program that finds a sequence of moves (in the form of a list of instructions) that, starting from two empty jugs, ends with exactly two gallons of water in the 4-gallon jug and no water in the 3-gallon jug.
Operations Research : Applications and Algorithms
4th Edition
ISBN:9780534380588
Author:Wayne L. Winston
Publisher:Wayne L. Winston
Chapter17: Markov Chains
Section: Chapter Questions
Problem 12RP
Related questions
Question
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps
Recommended textbooks for you
Operations Research : Applications and Algorithms
Computer Science
ISBN:
9780534380588
Author:
Wayne L. Winston
Publisher:
Brooks Cole
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
Operations Research : Applications and Algorithms
Computer Science
ISBN:
9780534380588
Author:
Wayne L. Winston
Publisher:
Brooks Cole
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:
9781337508841
Author:
Carey
Publisher:
Cengage