Jump to content
  • Advertisement
Sign in to follow this  
davidrachel

do you know this water jug problem

This topic is 4208 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

you have two jugs,3 gallon one and 4 gallon one ,doesn't have any markers on it,you fill this jugs with pump,how to fill 2 gallons of water in 4 gallon jug? anybody know answer plz reply..

Share this post


Link to post
Share on other sites
Advertisement
What does this have to do with artificial intelligence?
I've heard variations of this puzzle before.
Interestingly (is that a word?), I don't think ai would have much trouble solving this problem (genetic algorithms/minimax would solve this easily).

1st solution: Fill the 3 gallon jug, and pour it into the 4 gallon jug.
Fill the 3 gallon jug again and begin pouring it into the 4 gallon jug but stop when the 4 gallon jug is full.

There is another solution but it's not perfect because it depends on the dimensions and mass of the jugs:

Fill the 4 gallon jug and pour it into the 3 gallon jug till there is one gallon left. Empty the 3 gallon jug, and pour the 1 gallon into it.
Fully fill the 4 gallon jug, then submerge the 3 gallon jug in it so the tops are level - it will displace roughly 3 gallons and there will be 1 gallon left in the large jug. Step 3: Profit!

Edit: Just thought of another solution:

Fill the 4 gallon jug and pour it into the 3 gallon jug till there is one gallon left. Empty the 3 gallon jug, and pour the 1 gallon into it.
Fully fill the 4 gallon jug, then pour it into the 3 gallon jug till it is full. There is now 2 gallons left.

Share this post


Link to post
Share on other sites
Quote:
Original post by stevenmarky
What does this have to do with artificial intelligence?
I've heard variations of this puzzle before.
Interestingly (is that a word?), I don't think ai would have much trouble solving this problem (genetic algorithms/minimax would solve this easily).


Why? Why? whyyyyyy would you use genetic algorithms to solve a problem like that? Strong basics, guys. Even minimax is innapropriate. Simple state representation, very few actions possible, no good scoring/heuristic possible, solution is very short: this is the job for a simple breadth-first search.

Share this post


Link to post
Share on other sites
Quote:
Original post by SteadtlerWhy? Why? whyyyyyy would you use genetic algorithms to solve a problem like that? Strong basics, guys. Even minimax is innapropriate. Simple state representation, very few actions possible, no good scoring/heuristic possible, solution is very short: this is the job for a simple breadth-first search.

That's my opinion too. If you prefer solutions that don't waste a lot of water, use Dijkstra's algorithm (very similar to breadth-first search).

Share this post


Link to post
Share on other sites
Quote:
Original post by Steadtler
Why? Why? whyyyyyy would you use genetic algorithms to solve a problem like that? Strong basics, guys. Even minimax is innapropriate. Simple state representation, very few actions possible, no good scoring/heuristic possible, solution is very short: this is the job for a simple breadth-first search.

You're right, GAs aren't appropriate for this. So I guess NNs must be the way to go. [grin]

Share this post


Link to post
Share on other sites
Die Hard 3, FTW.

I've had this come up in school, during an interview, and even as a puzzle in a D&D campaign. There's really no trick to it, just brute force your way to a solution. Either way you go (which jug you start with, I mean) will get you there.

Share this post


Link to post
Share on other sites
Quote:
Original post by CyberSlag5k
Die Hard 3, FTW.

I've had this come up in school, during an interview, and even as a puzzle in a D&D campaign. There's really no trick to it, just brute force your way to a solution. Either way you go (which jug you start with, I mean) will get you there.


Wow. Im no big fan of puzzle questions in interviews, I would avoid like the plague any business that ask such a cliché puzzle.

Cheers to Sneftel who is trying to raise my temper :P

Share this post


Link to post
Share on other sites
I guess I just meant any brutish force algorithm would solve this easily.
Quote:

Why didn't you say that then?

Shutup!
Well anyway, I have a generic minimax algorithm which could be applied to this problem easily (you could also set the amount of players, in this case it would be one).

Share this post


Link to post
Share on other sites
Quote:
Original post by stevenmarky
I guess I just meant any brutish force algorithm would solve this easily.
Quote:

Why didn't you say that then?

Shutup!
Well anyway, I have a generic minimax algorithm which could be applied to this problem easily (you could also set the amount of players, in this case it would be one).


How would you score each "board" for minimax? Quantity of water in each jug is no indication of or close you are to "winning"

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!