2.2 Water Jugs Problem


  • Water jugs problem: We have one 3 litre jug, one 5 litre jug and an unlimited supply of water. The goal is to get exactly one litre of water into either jug. Either jug can be emptied or filled, or poured into the other.
    [Water Jugs Problem Figure]
  • A state in this problem could be represented with just a pair of numbers. The first representing the number of litres of water in the 5 litre (large) jug, and the second representing the number of litres of water in the 3 litre (small) jug.

  • The initial state would typically be: (0,0) to represent the fact that both jugs start off empty.

  • The final state would similarly be represented as: (0,1).

  • The operators for this problem could include:
    1. Fill the 5 litre jug to capacity from a water source
    2. Fill the 3 litre jug to capacity from a water source
    3. Empty the 5 litre jug into a drain
    4. Empty the 3 litre jug into a drain
    5. Pour from the 3 litre jug into 5 litre jug until capacity reached
    6. Pour from the 5 litre jug into 3 litre jug until capacity reached


[MAIN PAGE] [PREVIOUS PAGE] [NEXT PAGE]
RMiT Copyright © 1999. Department of Computer Science, RMIT University.
Last Modified: 19th June, 1999.