Newbie : Help in water jug problem
Author Message
Newbie : Help in water jug problem

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?".

Tue, 13 May 2003 03:00:00 GMT
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?".

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

Tue, 13 May 2003 03:00:00 GMT
Newbie : Help in water jug problem

"Eugene" wrote

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

I think that this problem has been discussed before in this newsgroup,
months ago.
You can try looking at old messages to this newsgroup using Deja News.
( Is it at "www.deja.com" ?   Or "www.dejanews.com" ?  )
You can probably search for the key word "water".

Quote:
> i need to pass it up tomorrow.

You've left it a bit late.

--
Martin Sondergaard.

Wed, 14 May 2003 03:08:44 GMT

 Page 1 of 1 [ 3 post ]

Relevant Pages