The Camel and Bananas — Puzzle for Interview rounds

Question :

A person has 3000 bananas and a camel. The person wants to transport the maximum number of bananas to a destination which is 1000 KMs away, using only the camel as a mode of transportation. The camel cannot carry more than 1000 bananas at a time and eats a banana every km it travels. What is the maximum number of bananas that can be transferred to the destination using only camel (no other mode of transportation is allowed).

Solution :

If the camel doesn’t eat a banana while returning, which means when it doesn’t have a banana, then the maximum number of bananas that can be transferred will be 833.

Let us divide the journey into 3 parts. First, the camel takes 1000 bananas and travels 333 KMs and puts the remaining bananas (1000–333 = 667) at first intermediate place and returns back to the source. Similarly, two more times, the camel takes 1000 bananas and travel for 333 KMs and put there remaining. Now, the total numbers of bananas are 2001 at the first intermediate place.

Again, the camel takes 1000 bananas and travels 500 KMs and puts the remaining bananas(1000–500=500) at second intermediate place and returns back to first intermediate place. Similarly one more times, the camel takes 1000 bananas and travels for 500 KMs and put there remaining bananas. Now, the total number of bananas is 1000 at the second intermediate place.

At last, the camel takes 1000 bananas and travels the remaining journey to 167 KMs. Thus, the total number of bananas is 833 at the final destination.

So, the maximum number of bananas can be transferred is 833, if the camel doesn’t eat a banana while returning.

Thanks for Reading

Placewit grows the best engineers by providing an interactive classroom experience and by helping them develop their skills and get placed in amazing companies.

Learn more at Placewit. Follow us on Instagram and Facebook for daily learning.

--

--

--

Upskilling students for tech placements!

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Judging Effies and West 44th Street, NYC

The importance of standardization in the age of RPA

A software engineer’s view of pandemic

An introvert’s guide to surviving conferences

Something I Learned About Wait-Staff in My Restaurants Which Is Indispensable Knowledge.

LeadWise Academy Week #2 Reflections: Relatedness

What I Learned As A Cat Food Brand Hand Model

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Placewit

Placewit

Upskilling students for tech placements!

More from Medium

Bee Travel Puzzle

Google Interview Question — LeetCode 1423

Designing an Engineering Take Home Assignment — Part A

A pen lying on a white sheet of paper with some equations on it

Minimum Moves to Reach Target Score