Tuesday, April 8, 2014

LISP program for Water - Jug problem

DEPTH-FIRST SOLUTION FOR THE WATER - JUG PROBLEM

There are two jugs, one holding 3 gallons and the other 5 gallons of water. The following activities can be done with the jugs: they can be filled, emptied, and dumped one into the other either until the poured into jug is full or until the poured-out-of jug is empty. Devise a sequence of actions that will produce 4 gallons of water in the larger jug.

2 comments: