Professional Documents
Culture Documents
You are given 20 Gallon, 13 gallon and 7 Gallon water jugs. The 20 Gallon jug is
full of water. Neither of them has measuring mark on it. How can you get exactly
10 Gallon of water in 20 Gallon and 13 Gallon jug? Write down production rules
and steps followed. (09 Marks)
Answer:
• Here, we are provided with three jugs: one having the capacity to hold 20
Gallons of water, second to hold 13 Gallon and the third has the capacity to
hold 7 Gallons of water.
• There is no other measuring equipment available and the jugs also do not
have any kind of marking on them.
• So, the agent’s task here is to fill 10 Gallon of water in 20 Gallon and 13
Gallon jug each by using only these three jugs and no other material.
• Initially, 20 Gallon jug is full of water and rest jugs are empty.
Rule Initial
Condition Final State Description of action taken
No. State
1 (x,y,z) If x<20 (20, y, z) Fill the 20 Gallon jug completely
2 (x,y,z) If y<13 (x, 13, z) Fill the 13 Gallon jug completely
3 (x,y,z) If z<7 (x, y, 7) Fill the 7 Gallon jug completely
Pour some part from the 20
4 (x,y,z) If x>0 (x-d, y, z)
Gallon jug
Pour some part from the 13
5 (x,y,z) If y>0 (x, y-d, z)
Gallon jug
Pour some part from the 7 Gallon
6 (x,y,z) If x>0 (x, y, z-d)
jug
7 (x,y,z) If x>0 (0, y, z) Empty 20 Gallon Jug completely
8 (x,y,z) If y>0 (x, 0, z) Empty 13 Gallon Jug completely
9 (x,y,z) If x>0 (x, y, 0) Empty 7 Gallon Jug completely
Pour some water from 13 Gallon
10 (x,y,z) If (x+y) <33 (20, y-[20-x], z)
to fill 20 Gallon jug completely
Pour some water from 20 Gallon
11 (x,y,z) If (x+y) <33 (x-[13-y], 13, z)
to fill 13 Gallon jug completely
Pour some water from 20 Gallon
12 (x,y,z) If (x+z) < 27 (x-[7-z], y, 7)
to fill 7 Gallon jug completely
Pour some water from 7 Gallon to
13 (x,y,z) If (x+z) < 27 (20, y, z-[20-x])
fill 20 Gallon jug completely
Pour some water from 13 Gallon
14 (x,y,z) If (y+z) < 21 (x, y-[7-z], 7)
to fill 7 Gallon jug completely
Pour some water from 7 Gallon to
15 (x,y,z) If (y+z) < 21 (x, 13, z- [13-y])
fill 13 Gallon jug completely
Pour all water from 13 Gallon jug
16 (x,y,z) If (x+y) <33 (x+y, 0, z)
to the 20 Gallon jug
Pour all water from 20 Gallon jug
17 (x,y,z) If (x+y) <33 (0, x+y, z)
to the 13 Gallon jug
Pour all water from 7 Gallon jug to
18 (x,y,z) If (x+z) < 27 (x+z, y, 0)
the 20 Gallon jug
Pour all water from 20 Gallon jug
19 (x,y,z) If (x+z) < 27 (0, y, x+z)
to the 7 Gallon jug
Pour all water from 7 Gallon jug to
20 (x,y,z) If (y+z) < 21 (x, y+z, 0)
the 13 Gallon jug
Pour all water from 13 Gallon jug
21 (x,y,z) If (y+z) < 21 (0, 0, y+z)
to the 7 Gallon jug
The listed production rules contain all the actions that could be performed by the
agent in transferring the contents of jugs. But, to solve the water jug problem in a
minimum number of moves, following set of rules in the given sequence should be
performed:
Solution of water jug problem according to the production rules:
On reaching the 48th attempt, we reach a state which is our goal state. Therefore,
at this state, our problem is solved.