Camel and Banana Puzzle

Solve the Camel and Banana Puzzle

Go through the page to find the detailed solution to Camel and Banana Puzzle. The owner of a banana plantation has a camel. He wants to transport his 3000 bananas to the market, which is located in the desert. The distance between his banana plantation and the market is about 1000 kilometers. So he decided to take his camel to carry the bananas. The camel can carry a maximum of 1000 bananas at a time, and it eats one banana for every kilometer it travels.

What are the most bananas you can bring over to your destination?

Camel and Banana Puzzle

Camel and Banana Puzzle

Go through the page to find the detailed solution to Camel and Banana Puzzle. The owner of a banana plantation has a camel. He wants to transport his 3000 bananas to the market, which is located in the desert. The distance between his banana plantation and the market is about 1000 kilometers. So he decided to take his camel to carry the bananas. The camel can carry a maximum of 1000 bananas at a time, and it eats one banana for every kilometer it travels.

What are the most bananas you can bring over to your destination?

Camel and Banana Puzzle

Solution

At first look, it seems that the person cannot transfer any banana as the camel can carry at most 1000 bananas and going to eat all bananas when the destination is reached.

The trick is to transfer bananas to an intermediate point, then transfer all bananas from the intermediate point to the destination.
So we have to take an approach that the Camel drops the bananas in between and then returns to point A to pick up bananas again.

The owner of a banana plantation has a camel.

Detail Analysis:

First of all, the brute-force approach does not work

i.e., if the Camel starts by picking up the 1000 bananas then either the Camel will go up to 1000 Km but then he will neither move forward nor move back because there is no banana left. Now if he travels 500km and returns then it is also not useful because then he will eat all 1000 bananas in going 500 km and coming back. So, this method failed.

So we have to take an approach that the Camel drops the bananas in between and then returns to point A to pick up bananas again.

Since there are 3000 bananas and the camel can only carry 1000 bananas, Camel will have to make 3 trips to carry them all to any point in between.

When bananas are reduced to 2000 then Camel can shift them to another point in 2 trips and when the number of bananas left are

Solve the Camel and Banana Puzzle

In the first part, P1, to shift the bananas by 1Km Camel will have to

1. Move forward with 1000 bananas – Will eat up 1 banana on the way forward 

2. Leave 998 bananas after 1 km and return with 1 banana – will eat up 1 banana on the way back

3. Pick up the next 1000 bananas and move forward – I will eat up 1 banana on the way forward 

4. Leave 998 bananas after 1 km and return with 1 banana - will eat up 1 banana on the way back

5. Will carry the last 1000 bananas from point a and move forward – will eat up 1 banana

Note: After point 5 the camel does not need to return to point A again.

So to shift 3000 bananas by 1km Camel will eat up 5 bananas.

After moving to 200 km the camel would have eaten up 1000 bananas and is now left with 2000 bananas.

Hence, the length of part P1 is 200 Km.

Now in the Part P2, the Camel needs to do the following to shift the Bananas by 1km

1. Move forward with 1000 bananas - Will eat up 1 banana on the way forward

2. Leave 998 bananas after 1 km and return with 1 banana - will eat up this 1 banana on the way back

3. Pick up the next 1000 bananas and move forward - Will eat up 1 banana on the way forward

Note: After point 3 the camel does not need to return to the starting point of P2.

So to shift 2000 bananas by 1km Camel will eat up 3 bananas.

After moving to 333 km the camel would have eaten up 1000 bananas and is now left with the last 1000 bananas.

Note:

The camel will be able to cover 333.33 km, 

I have ignored the decimal part because it will not make a difference in this example.

Hence the length of part P2 is 333 Km.

Now, for the last part, P3, the Camel only has to move forward. He has already covered 533 (200+333) out of 1000 km in Parts P1 & P2. Now he has to cover only 466 km and he has 1000 bananas.

He will eat up 466 bananas on the way forward, and at point B the Camel will be left with only 533 Bananas.

Prime Course Trailer

Related Banners

Get over 200+ course One Subscription

Courses like AI/ML, Cloud Computing, Ethical Hacking, C, C++, Java, Python, DSA (All Languages), Competitive Coding (All Languages), TCS, Infosys, Wipro, Amazon, DBMS, SQL and others

Checkout list of all the video courses in PrepInsta Prime Subscription

Checkout list of all the video courses in PrepInsta Prime Subscription