You are on page 1of 4

Question:

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.

So, to solve this problem, following set of rules were proposed:

Production rules for solving the water jug problem

Here, let x denotes the 20-gallon jug


y denotes the 13-gallon jug
z denotes the 7-gallon jug

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:

S.No. 20 Gallon jug 13 Gallon Jug 7 Gallon Jug Rule followed


1 20 0 0 Initial State
2 0 0 0 Rule No 7
3 0 13 0 Rule No 2
4 0 6 7 Rule No 14
5 6 0 7 Rule No 16
6 6 7 0 Rule No 20
7 6 7 7 Rule No 3
8 6 13 1 Rule No 15
9 7 13 0 Rule No 18
10 7 6 7 Rule No 14
11 7 0 7 Rule No 16
12 7 7 0 Rule No 20
13 7 7 7 Rule No 3
14 7 13 1 Rule No 15
15 8 13 0 Rule No 18
16 8 6 7 Rule No 14
17 8 0 7 Rule No 16
18 8 7 0 Rule No 20
19 8 7 7 Rule No 3
20 8 13 1 Rule No 15
21 9 13 0 Rule No 18
22 9 6 7 Rule No 14
23 9 0 7 Rule No 16
24 9 7 0 Rule No 20
25 9 7 7 Rule No 3
26 9 13 1 Rule No 15
27 10 13 0 Rule No 18
28 10 0 0 Rule No 8
29 10 0 7 Rule No 3
30 10 7 0 Rule No 20
31 10 7 7 Rule No 3
32 10 13 1 Rule No 15
33 10 0 1 Rule No 8
34 10 1 0 Rule No 20
35 10 1 7 Rule No 3
36 10 8 0 Rule No 20
37 10 8 7 Rule No 3
38 10 13 2 Rule No 15
39 10 0 2 Rule No 8
40 10 2 0 Rule No 20
41 10 2 7 Rule No 3
42 10 9 0 Rule No 20
43 10 9 7 Rule No 3
44 10 13 3 Rule No 15
45 10 0 3 Rule No 8
46 10 3 0 Rule No 20
47 10 3 7 Rule No 3
48 10 10 0 Rule No 20

On reaching the 48th attempt, we reach a state which is our goal state. Therefore,
at this state, our problem is solved.

You might also like