A somewhat well-known puzzle is described as such:

You have a pile of 3,000 bananas. You wish to transport them to a place 1,000 miles away on the back of a camel; however, the camel can only carry a maximum of 1,000 bananas, and will eat one banana every mile it travels (and will not go anywhere if it does not have any bananas). However, you can load and unload as many bananas as you want anywhere. What is the most bananas you can bring over to your destination?

Obviously you can't just load up 1,000 bananas and go, because the camel will have eaten them all by the time you get there.

I'd never figured out the answer by myself before. Does anybody have any insights into how to solve this problem and other problems like it?

  • 2
    The camel can only carry 1,000 bananas at once. – Joe Z. May 19 '14 at 2:29
  • 7
    You can't add 1 banana when you're a mile away from the pile. – Joe Z. May 19 '14 at 2:33
  • 1
    Does it have to be the same camel the entire time? – igelkott May 19 '14 at 10:59
  • 1
    Yes, it's always the same camel. – Joe Z. May 19 '14 at 13:48
  • 2
    Usually the camel eats the banana at the end of a mile, but you can even assume the camel eats bananas continuously. – Joe Z. Nov 26 '14 at 16:21

10 Answers 10

up vote 32 down vote accepted

Solution for $n$ bananas, where $n$ is the number of bananas you own, and $c$ is the number of bananas the camel can carry:

- For bananas $0 \rightarrow c$ the cost to move a banana is $1$ banana per mile.
- For bananas $c+1 \rightarrow 2c$, the cost to move a banana is $3$ bananas per mile.
- For bananas $2c+1 \rightarrow 3c$, the cost to move a banana is $5$ bananas per mile.
- etc.

This is because, if the camel moves the bananas 1 mile at a time, he needs to make two trips for each load beyond his current capacity.

Define $t = \lfloor\frac{n}{c}\rfloor$ Therefore, the total number of miles the camel can reach is:

$$\left(\sum_{k=1}^{t} \frac{c}{2k - 1}\right) + \frac{(n \bmod c)}{2t+1}$$

In particular, plugging in the given $n = 3000$ and $c = 1000$, we have that the camel can travel

$$1000 + 333 + 200 = 1533 \text{ miles}$$

To figure out how many bananas remain for a given distance,

Subtract the extra miles and multiply back at the rate given above.

For the first $1000$ miles, this number is just the distance beyond the total capacity:

$1533 - 1000 = 533$, or 533 bananas.

  • If we reformulate the question as How many bananas do we need at the start if we must get X bananas to the finish line, will the answer converge to the rocket fuel equation for increasing X and distance? Not sure if it will, but the same principle is at work here I think. Increasing the amount X by a bit will cause the original amount of bananas to increase significantly... – user1429080 Nov 27 '14 at 11:37
  • Divide the total answer by 1.609 to convert km to mi. :-) – jvriesem Nov 6 '16 at 17:01

First of all, the brute-force approach does not work. If the Camel starts by picking up the 1000 bananas and try to reach point B, then he will eat up all the 1000 bananas on the way and there will be no bananas left for him to return to point A.

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.

<---p1---><--------p2-----><-----p3---->
A---------------------------------------->B
-----> ------> -------->
<----- <------
-----> ------>
<-----
----->

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

When bananas are reduced to 2000 then the Camel can shift them to another point in 2 trips and when the number of bananas left are <= 1000, then he should not return and only move forward.

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

  1. Move forward with 1000 bananas – Will eat up 1 banana in the way forward
  2. Leave 998 banana after 1 km and return with 1 banana – will eat up 1 banana in the way back
  3. Pick up the next 1000 bananas and move forward – Will eat up 1 banana in the way forward
  4. Leave 998 banana after 1 km and return with 1 banana - will eat up 1 banana in 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, the 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 in the way forward
  2. Leave 998 banana after 1 km and return with 1 banana - will eat up this 1 banana in the way back
  3. Pick up the next 1000 bananas and move forward - Will eat up 1 banana in 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, the 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.

Because it is a multiple of 3, after 333 times there is 1001 bananas left. Therefore, the camel must take 1000 bananas and then take 1 back with him to pick up the last banana, leaving him with 999 bananas. This would leave the camel at 334 km + 200 km, so the merchant only needs to travel 466 km, eating 1 banana for every km.

999 bananas - 466 bananas for each remaining km equals 533 bananas left at point B. Therefore, the merchant has 533 bananas to sell at point B.

  • 5
    I like the shift from miles to Km. – Shade May 28 '14 at 0:21
  • 2
    I believe you have the correct answer, but you should be careful about ignoring the decimal part of 333.33. In this case the cost of carrying the bananas that extra km from 333 to 334 (costing 3 bananas) is higher than abandoning a single banana at 333 and moving forward (costing two bananas) with the final 1000. – Jason May 28 '14 at 4:53
  • Agree with Jason, the result is correct, but the reasoning in ignoring .33 is not entirely correct. It should have been what Jason said, you abandon one banana after 333km. – justhalf Jul 3 '14 at 5:26

While the amount of bananas is larger than 2000, the camel will have to make 5 trips to shift them. At a cost of 1 banana per mile, this will cost 5 bananas per mile in total.
While the amount of bananas is larger than 1000, it takes 3 trips to shift them, so a total cost of 3 bananas per mile.
For the final stretch, it just takes a single banana per mile.

  1. 3000 - 2000 bananas (numbers given for first mile)
    1. Move 1000 bananas, feed 1, 2999 left.
    2. Go back, feed 1, 2998 left.
    3. Move 1000 bananas, feed 1, 2997 left.
    4. Go back, feed 1, 2996 left.
    5. Move 998 bananas, feed 1, 2995 left.
  2. 2000 - 1000 bananas (numbers given for first mile)
    1. Move 1000 bananas, feed 1, 1999 left.
    2. Go back, feed 1, 1998 left.
    3. Move 999 bananas, feed 1, 1997 left.
  3. 1000 bananas (numbers given for first mile)
    1. Move 1000 bananas, feed 1, 999 left.

So at 5 bananas/mile you're down to 2000 bananas after 200 miles. Your total mileage then improves to 3 bananas/mile for the next 333 miles. After that, you're on the home stretch and move at 1 banana/mile for the remaining 467 miles (after which you'll have 533 bananas left).

A few things to note:

  • It is not necessary to move in one mile increments. For the first stretch, you can load up with 1000 bananas, move 200 miles, unload 600, and use 200 for your return trip. You do the same thing again, and after the last trip, you can unload 800, or rather, load 200 to be at a full 1000 again.
  • After completing the 333 mile stretch, you're 467 miles away from your destination, with exactly 1001 bananas. There are now two solutions:
    1. Eat a banana (or leave it to rot) to have a nice, integer solution.
    2. Use it to move for a total of 333⅓ miles. If the camel needs to be fed after walking a full mile, you will now make it to your destination with ⅓ of a mile to spare, which should save you a banana, leaving you with 534 bananas.
      Congratulations, you're now banana king!
  • 4
    You are the banana king! – JeffE May 28 '14 at 4:13
  • 4
    You won't feed a starving camel at the end of a long trip? Shame on you! – Neil Jul 4 '14 at 13:04
  • 6
    He's not starving, he still has 1/3 banana left in him! Also, check the map for where camels live and where bananas grow. Pretty much non-overlapping. It's fictional! They are lying to us! It's a conspiracy! – SQB Jul 4 '14 at 13:21
  • 5
    @Neil He just got fed 2466.66 bananas, I'm sure he'll manage. – Damien H Nov 27 '14 at 4:19

First leg of the journey:

  • Load 1000,
  • Drop 4 bananas every mile for 200 miles, feeding the camel from own supply.
  • The route is primed for 4 passes of the camel:
    • return
    • take another 1000 bananas
    • return
    • take remaining 1000 bananas.

Second leg, starting with mile 200:

  • load 1000
  • drop 1 banana a mile away, then 2 bananas every next mile for another 333 miles, for 534 miles total.
  • return
  • pick 1000 bananas
  • on the first mile eat a banana from own supply, then continue using the ones left.
  • arrive at 534th mile with 999 bananas.

Third leg of the journey:

  • Feed the camel the last banana on the ground, then starting with 535th mile, keep using bananas from your supply of 999.
  • use up 465 bananas from own supply for the remaining 465 miles.

You're left with 999-465 = 534 bananas.

  • The first practical solution, which doesn't require 2000 times loading and unloading the camel! - good creative answer! – Falco Jun 11 '15 at 13:18

This is the best answer that does not require stopping every mile. Take

1000 bananas

go

333 1/3 miles

and drop off

666 2/3 bananas.

Go back and repeat 2 more times. Now you are on mile

333 1/3 with 2000 bananas. Take 1000 bananas and go forward 500 miles. Drop off 500 bananas.

Go back and repeat. Now you are on mile

833 1/3 with 1000 bananas. Go forward another 167 2/3 miles to reach the market with 833 1/3 bananas.

  • 2
    The puzzle omits a fact -- the camel is happy to go get more bananas if it has no bananas on its back. – Martin Sep 7 '16 at 4:49
  • 3
    It says right in the question statement that the camel will not go anywhere if it doesn't have any bananas. – Joe Z. Sep 7 '16 at 4:51

Here is my solution, where camel arrives with 500 bananas:

  1. Load 1000 bananas, travel 250 miles (point A), unload 500 bananas, use 250 remaining to go back.
  2. Load 1000 bananas, travel 250 miles to point A, load 250 bananas (so camel has 1000 bananas again, with 250 remaining at point A), travel 250 miles more (point B), unload 500 bananas, travel 250 miles to point A, load 250 there, travel back to the starting point.
  3. Load 1000 bananas, go 500 miles to point B, load 500 bananas there, arrive to the destination with 500 bananas.

Now, since the right answer is 534, the question is: where did I lose 34 bananas?

  • 1
    This is simply a suboptimal solution. Just because you have a solution doesn't mean that it's the best. – boboquack Mar 13 '17 at 8:24
  • I was wondering what is so suboptimal in my solution. I think it's the fact that my camel travels less loaded on average. – beetoom Mar 14 '17 at 7:37
  • Probably. In any case, look at the bridge and torch problem - where the obvious solution isn't the best. – boboquack Mar 14 '17 at 7:44
  • 1
    You're walking 250 miles on a section where you have to pass 5 times. You should shorten this to arrive at the optimal solution. But don't shorten this section too much, because then you haven't spent 1000 bananas, which means you have more than 2000 left, which means you'll have to walk another section five times as well. – florisla Nov 22 '17 at 10:54
  1. Load up 1000 bananas. Go forward 200 miles. Drop down 600 bananas. Go backward 200 miles to start point.
  2. Load up 1000 bananas. Go forward 200 miles, here pick up 200 bananas. Go forward 333.5 miles. Drop down 333 bananas. Go backward 333.5 miles, here pick up 200 bananas. Go backward 200 miles to start point.
  3. Load up last 1000 bananas. Go forward 200 miles, here pick up last 200 bananas. Go forward 333.5 miles here pick up last 333 bananas. Go forward 466.5 miles to finish, and here drop down last 533 bananas.

You will made 7 loads, 3 unloads and 2 come backs.

The traditional text of the problem is that the camel will eat 1 banana per mile if there is banana to eat. In this case...

Assume the camel eats 1 banana at the end of 1 mile (later we will adjust that).

Start with 1000 bananas in a (big) basket.
For each mile, the camel eats 1 banana, and you drop one on the road. After 500 miles, the basket has no banana and there are 500 bananas along the road (one at each mile). With the 500th banana return to A. Fill the basket with another 1000 bananas. Feed the camel with 1 banana per mile. After 500 miles the trunk has 500 bananas, and 500 bananas remains along the road. Continue for additional 250 miles while feeding the camel 1 banana per mile and dropping 1 banana per mile on the road. At mile 750 the basket has zero bananas and 750 bananas are along the road. Return to A with the last banana left in the basket. At A, fill again the the basket with 1000 bananas. Now, feed the camel at each mile with the 750 bananas left along the road. The camel will go through 750 miles while the basked contains 1000 bananas. For the final 250 miles, feed the camel with 250 bananas and you reach B with 750 bananas in the basket. Ideally you reach B with 750 bananas.
Now back with the initial assumption (that the camel eats at the end of the mile) and change to the assumption that the camel eats 1 banana at the beginning of the mile (pay first!). In this case, you can give 1 banana to the camel and even so fill the basket with 1000 bananas, but you are left with 1999 bananas at A. Follow the same reasoning as before. Back again at A, where you have 1999 bananas, fill the basket with 1000 bananas, and feed the camel with 1 banana, leaving 998 bananas at A. Then, finally, back to A again (where there are 998 bananas), fill the basket with 997 and give one to the camel. Since in the last journey you start with 977 (instead of 1000) you reach B with 747 bananas (instead of 750). You have 747 bananas at B.

  • Hello and welcome to PSE. Please hide your answers in a spoiler. – rhsquared Apr 11 at 6:22
  • Why do you think you can travel the 500 (or 750) miles back to A with a single banana? – Rubio Apr 11 at 23:17

I have a solution that has a better result than 534. I'm not sure it is the best solution.

1. The camel carries 1000 bananas for 250 miles. Thus, he will leave 750 bananas after each trip at the 250th miles. After 3 trips, there are 2,250 bananas at the 250th miles.
2. The camel carries 1000 bananas each trip for 2 trips for 500 miles. At the 750th mile, we have 1000 bananas.
3. As we have 250 miles left, the camel then makes a final trip, carrying 1000 bananas. He will consume 250 bananas, leaving 750 bananas at B.

  • 4
    The camel also eats bananas when it walks back. It'll refuse to walk from the pile if you leave all 750 bananas there. – Joe Z. Sep 5 '16 at 4:42
  1. Load up camel with 1000 bananas. Travel 500 miles, leaving 500 bananas. Dump them there.

  2. Do same trip again and leave 500 bananas at 500 mile mark.

  3. Do same trip again and pick up one of the 500 banana piles when you hit the 500 mile mark. Now you are at 1000 again.

  4. at 750 mile mark, drop your (now 750) bananas

  5. Go back to mile 500, pick up your 500 bananas

  6. Go to mile 750, and now you have 250 left

  7. Pick up your 750 that you previously left

  8. Now you have 1000 at mile 750

  9. Walk the remaining 250 miles, leaving 750

  10. Eat one for yourself and market the remaining 749 bananas.

749! Woo Hoo!

***Edit: I was basing mine off 538's recent Riddler, which says that the camel can travel w/o bananas as long as he doesn't sniff any bananas. So, whoops!

http://fivethirtyeight.com/features/how-many-bananas-does-it-take-to-lead-a-camel-to-market/

  • 3
    The camel will not go anywhere if it doesn't have any bananas. – Sconibulus Sep 8 '16 at 14:15
  • 2
    Agreed with @Sconibulus. You haven't taken into account that the camel will need to eat bananas on each return journey too. – Rand al'Thor Sep 8 '16 at 14:30

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.