• 27,060

Posts Tagged ‘camel’

3000 bananas and 1000 miles and a camel?

Posted by guptaradhesh on December 1, 2010

This seems a common puzzle but has a good logical solution. My TA for algorithms subject posted it on his webpage and I then worked around to figure out the solution. Here is a good solution explanation which I found somewhere on web:

It initially seems that the answer is 0 since it would take 3 trips to the market and the camel will have eaten all 3000 bananas by then. But this doesn’t take into account that his load is going to be reduced along the way as the camel eats the bananas.

Let’s take it mile by mile. Since initially there are 3000 bananas and the camel only can carry 1000 at a time, the camel must make 3 trips forward: forward with the 1st 1000, back, forward with the 2nd 1000, back, and forward with the last 1000. Note that it takes 3 trips forward and 2 trips back to go the mile. For the 1st mile the camel carries 1000 bananas forward and eats 1, it eats 1 banana on the way back, carries 1000 bananas forward and eats 1, eats 1 going back, and 1000 bananas forward and eats 1. So, after the 1st mile there are 1000 – 1 – 1 + 1000 – 1 – 1 + 1000 – 1 or 2995 bananas left. So initially, for every mile traveled forward (in 3 trips), the camel eats 5 bananas.

However, after 200 miles the load will be down to 2000 bananas and the camel only needs to make 2 trips forward: forward, back, forward. For each of the next 333 and 1/3 miles the camel will eat 3 bananas to carry the load ahead. So after 533 1/3 (200 + 333 1/3) miles the load will be eaten down to 1000 bananas.

For the next 466 2/3 miles till the camel gets the market, it will eat 1 banana per mile to carry the load. 1000 – 466 2/3 = 533 1/3 bananas left. So the camel will eat a total of 200 * 5 + 333 1/3 * 3 + 466 2/3 = 2466 2/3 bananas to get the entire 3000 bananas to market so the grower will have 533 1/3 bananas left to sell. Maybe 533 because who would want to eat a banana 2/3 of which a smelly camel has eaten. The script accepted 532, 533, 533 1/3, 533.333, and 534 depending on rounding and fractions.

Also, he’ll have to sell his camel there because he doesn’t have the bananas to get it back.