How to model 3 glass problem to graph? The barman gives you three glasses whose sizes are 1000ml, 700ml, and 400ml, respectively. The 700ml and 400ml glasses start out full of beer, but the 1000ml glass is initially empty. You can get unlimited free beer if you win the following game: Game rule: You can keep pouring beer from one glass into another, stopping only when the source glass is empty or the destination glass is full. You win if there is a sequence of pourings that leaves exactly 200ml in the 700ml or 400 ml glass.
cimithe4c
Answered question
2022-10-20
How to model 3 glass problem to graph? The barman gives you three glasses whose sizes are 1000ml, 700ml, and 400ml, respectively. The 700ml and 400ml glasses start out full of beer, but the 1000ml glass is initially empty. You can get unlimited free beer if you win the following game: Game rule: You can keep pouring beer from one glass into another, stopping only when the source glass is empty or the destination glass is full. You win if there is a sequence of pourings that leaves exactly 200ml in the 700ml or 400 ml glass.
Answer & Explanation
bibliothecaqz
Beginner2022-10-21Added 12 answers
Step 1 I would model your problem as a rather huge graph with nodes which correspond to the state where ml of beer are in the 1000ml glass, ml of beer are in the 700ml glass, and ml of beer are in the 400ml glass. Of course, , , and . Two nodes u and v are connected by a directed edge if the state corresponding to u can be transformed to the state corresponding to v by a valid move. Step 2 As an example, your initial node will be and will be connected to and since you can either pour the full 700ml glass into the 1000ml glass or the 400ml glass into the 1000ml glass. Inside this graph you have to find a path from to or for some , , and . To simplify your task you can connect all these possible end nodes to an artifitial node v and look for a -v-path instead.