My FeedDiscussionsHeadless CMS
New
Sign in
Log inSign up
Learn more about Hashnode Headless CMSHashnode Headless CMS
Collaborate seamlessly with Hashnode Headless CMS for Enterprise.
Upgrade ✨Learn more

[Fun Challenge] Can you solve "Fox, Goose and Corn" problem through code?

Sandeep Panda's photo
Sandeep Panda
·Dec 17, 2018

So, here is the problem:

Once upon a time a farmer went to a market and purchased a fox, a goose, and a bag of beans. On his way home, the farmer came to the bank of a river and rented a boat. But in crossing the river by boat, the farmer could carry only himself and a single one of his purchases - the fox, the goose, or the bag of beans.

If left together, the fox would eat the goose, or the goose would eat the beans.

The farmer's challenge was to carry himself and his purchases to the far bank of the river, leaving each purchase intact. How did he do it?

Can you write a simple program to solve the above problem? 😀

  • 💡Use any language of your choice
  • 💡No limit on the Lines of Code (LoC)
  • 💡If possible, mention the time complexity of your solution