File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programming Diversions and the fly likes River Crossing: Bear, Goat, Cabbage, and You Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Other » Programming Diversions
Bookmark "River Crossing: Bear, Goat, Cabbage, and You" Watch "River Crossing: Bear, Goat, Cabbage, and You" New topic

River Crossing: Bear, Goat, Cabbage, and You

Mark Herschberg

Joined: Dec 04, 2000
Posts: 6037
This is an easy question.
You are traveling with your pet bear, pet goat, and pet cabbage (they make great pets--no mess!). You come to a river with a row boat. Only you can row the boat, and the boat is only big enough for one other item: the (small) bear, regular sized goat, and oversized cabbage. How do you get everything across the river?
The catch (there's always a catch) is that if you're not around (e.g. on the other side of the river) the goat will eat the cabbage. Likewise, if you leave the bear and goat unattended, the bear will eat the goat (studies show bears eat goats when stranded on riverbanks). How do you get them all across?
Greg Harris
Ranch Hand

Joined: Apr 12, 2001
Posts: 1012
1. take goat
2. take cabbage, bring goat back
3. leave goat, take bear
4. take goat (again)

Vivek Kumar

Joined: Sep 23, 2003
Posts: 9
Jenn Jenn

Joined: Jan 04, 2005
Posts: 1
This is alot like the problem i had to do in a math class a few years back, only it was with a fox, goose, and bucket of grain and the guy could only take 3 trips.It went like this, take the fox, go back, get the grain, go back and let the goose swim. But with this one it would probably be take the bear, the cabbage, then the goat.
Sonny Pondrom
Ranch Hand

Joined: Jun 05, 2001
Posts: 128
I think you forgot something. When you take the fox, the goose eats all the grain.

You have to start with the middle creature, in this case the goose.
[ January 07, 2005: Message edited by: Sonny Pondrom ]
I agree. Here's the link:
subject: River Crossing: Bear, Goat, Cabbage, and You
It's not a secret anymore!