What is operators in the water jug problem?

What is operators in the water jug problem?

Possible legal operators are:�� filling Jug-A, filling Jug-B, emptying Jug-A onto the ground, emptying Jug-B onto the ground, pouring Jug-A into Jug-B (until either Jug-A is empty or Jug-B is full), or pouring Jug-B into Jug-A (until either Jug-B is empty� or Jug-A is full).

How do you measure water in a jug?

Measure the Diameter

  1. Measure the bottom face of the bottle from one side to the other with a flat ruler. This is your bottle diameter.
  2. Multiply the diameter by pi (3.14), and the resulting number is your circumference. This is the width of your label.

How can you get exactly 2 gallons of water into the 4 gallon jug?

Neither jug has any measuring markings on it. How can you get exactly 2 gallons of water in the 4-gallon jug?…They are:

  1. We can fill a jug from the pump.
  2. We can pour water out of a jug to the ground.
  3. We can pour water from one jug to another.
  4. There is no measuring device available.

How the state is represented in water jug problem?

The state space for this problem can be described as the set of ordered pairs of integers (X, Y) such that X = 0, 1, 2, 3 or 4 and Y = 0, 1, 2 or 3; X is the number of gallons of water in the 4-gallon jug and Y the quantity of water in the 3-gallon jug.

What is state space for water jug problem?

How to pour water between two jugs of water?

I wrote a solution for a jug problem (given two jugs of water of different sizes find the steps needed to get specific amount of water in one of the jugs). I’m hoping for some input on my code.

How do you solve the water jug problem?

I have been practicing recursion lately and I came up with this code to solve the water jug problem, given two jugs of volume jug1 and jug2, where jug1 < jug2, obtain a volume t, where t < jug2. The algorithm below basically always pours from the smaller jug into the bigger jug, how would you improve the solution ?

Where are the water jugs in the puzzle?

You are on the side of the river. You are given a m liter jug and a n liter jug where 0 < m < n. Both the jugs are initially empty. The jugs don’t have markings to allow measuring smaller quantities.

How to fill a m liter jug with water?

Fill the m litre jug and empty it into n liter jug. Whenever the m liter jug becomes empty fill it. Whenever the n liter jug becomes full empty it. Repeat steps 1,2,3 till either n liter jug or the m liter jug contains d litres of water.