Newbie : Help in water jug problem

Quote:

> I need somehelp in creating a prolog program for the water jug problem. It

> is an assignment and i need to pass it up tomorrow. I tried so hard to

> understand the language but it seems worthless since the lecturer didn't

> provide any hint. Thus, is there any prolog guru in this group can give me a

> help by giving me a simple sample of the program. The question is like

> follow

> "You are given two jugs, a 4-gallon one and a 3-gallon one. Neither has any

> measuring markers on it. There is a tap that can be used to fill the jugs

> with water. How can you get exactly 2 gallons of water into the 4-gallon

> jug?".

answer :-

write('Fill the 3-gallon one. Throw the water from the 3-gallon one

into the 4-gallon one. Fill the 3-gallon one again. Throw as

much water as possible from the 3-gallon one into the 4-gallon

one. Empty the 4-gallon one. Throw the remainder of the 3-gallon

one into the 4-gallon one.

').

--

Gertjan van Noord Alfa-informatica, RUG, Postbus 716, 9700 AS Groningen

vannoord at let dot rug dot nl http://www.let.rug.nl/~vannoord