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

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



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  
 
 [ 3 post ] 

 Relevant Pages 

1. water-jug problem

2. Extended water-jug problem

3. water Jugs Problem

4. water water everywhere

5. Jugs problem

6. Art and all that Jazz: many tyrants will be tired urban jugs

7. newbie help - getline problem

8. Help: Dumb newbie problem with RB plugin SDK

9. Newbie problems - help?

10. Please help newbie with OSF COBOL problem

11. Can someone please help a Newbie with a redirection problem

12. Can anybody help a newbie with a Fatal Error problem

 

 
Powered by phpBB® Forum Software