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).
Let’s see what we can infer from the question:
- We have a total of 3000 bananas.
- The destination is 1000KMs
- Only 1 mode of transport.
- Camel can carry a maximum of 1000 banana at a time.
- Camel eats a banana every km it travels.
With all these points, we can say that person won’t be able to transfer any banana to the destination as the camel is going to eat all the banana on its way to the destination.
But the trick here is to have intermediate drop points, then, the camel can make several short trips in between.
Also, we try to maintain the number of bananas at each point to be multiple of 1000.
Let’s have 2 drop points in between the source and destination.
With 3000 bananas at the source. 2000 at a first intermediate point and 1000 at 2nd intermediate point.
3000 x km 2000 y km 1000 z km
——————–> | —————> | ———————–>
<——————- | <————– |
——————-> | —————> |
<—————— | |
——————-> | |
- To go from source to IP1 point camel has to take a total of 5 trips 3 forward and 2 backward. Since we have 3000 bananas to transport.
- The same way from IP1 to IP2 camel has to take a total of 3 trips, 2 forward and 1 backward. Since we have 2000 bananas to transport.
- At last from IP2 to a destination only 1 forward move.
Let’s see the total number of bananas consumed at every point.
- From the source to IP1 its 5x bananas, as the distance between the source and IP1 is x km and the camel had 5 trips.
- From IP1 to IP2 its 3y bananas, as the distance between IP1 and IP2 is y km and the camel had 3 trips.
- From IP2 to destination its z bananas.
We now try to calculate the distance between the points:
- 3000 – 5x = 2000 so we get x = 200
- 2000-3y = 1000 so we get y = 333.33 but here the distance is also the number of bananas and it cannot be fraction so we take y =333 and at IP2 we have the number of bananas equal 1001, so its 2000-3y = 1001
- So the remaining distance to the market is 1000 -x-y =z i.e 1000-200-333 => z =467.
Now, there are 1001 bananas at IP2. However the camel can carry only 1000 bananas at a time, so we need to leave one banana behind.
So from IP2 to the destination point camel eats 467 bananas. The remaining bananas are 1000-467=533.
So the maximum number of bananas that can be transferred is 533.
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.
Refer the following link for a detailed explanation: https://puzzling.stackexchange.com/a/232
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses
are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!