Problem Statement
You are standing in desert with camel and 3000 bananas. You have to transport these bananas using camel from point A to point B. Distance between points is 1000 Kms. Camel can take 1000 bananas at a time and also you have to feed him one banana per km. Now you have to find the way to transport highest number of bananas from point A to point B. You can store bananas between point A and B anywhere.
If you want to try out solution your self read next lined after you tried to solve it.
Here is the approach toward the solution.
First thought
Lets try to transport all 1000 bananas from point A to point B. If camel travels from point A to point B you will be left with no banana as you have to feed camel 1000 bananas for travel of 1000 kms. Also there is no way you can take camel back to point A as there is no banana. :)
If camel travels half of distance ie 500 kms and return back to point A. In this case camel will eat 500 banana when he reached at the middle and you have to carry 500 bananas back to point A so that camel can be feed while he is returning back. So you will reach at point A with out any banana out of 10000.
Divide the route
Let divide the route between A to B in three parts of 333 Kms,333 Kms and 334 Kms. Now camel will start from point A with 1000 bananas and will unload after travelling 333 Kms (Say point C). In this case camel will reach to this point with (1000-333) 667 bananas. For travelling back he needs 333 bananas so only 334 (667-333) bananas can be stored at point C. Now let's repeat same step again after reaching point A till there is no banana at point A. In this case camel has to travel
A->C 333 Kms
C->A 333 Kms
Bananas at point A = 2000
Bananas at point C = 334
A->C 333 Kms
C->A 333 Kms
Bananas at point A = 1000
Bananas at point C = 668
A->C 333 Kms
Bananas at point A = 0
Bananas at point C = 668+(1000-333) = 1335
Ok We reach at point C (333 Kms from point A and 667 Kms from point B) with 1335 bananas. Let's move ahead from point C to 333 Kms (Say point D) with 1000 bananas. Now we have 1000-333 = 667 bananas when reached at point D. Now we have to decide to go back to C to get rest 335 bananas from point C or go ahead to point B.
Say let's move to point C from point D so we will unload 667-333 = 334 bananas at point D. After reaching point C we will pick 335 bananas and will reach at point D with 2 bananas so we have 336 bananas at point D. so if we move from point D to point B we will reach with only 2 bananas (336-334=2)
Here is travel plan between C to D
C->D 333 Kms
D->C 333 Kms
Bananas at point C = 335
Bananas at point D = 334
C->D 333 Kms
Bananas at point C = 0
Bananas at point D = 334 + (335-333) = 336
In case if we decide not to go back to point C then we will reach point B from point D with 333 bananas at hand.
C->D 333 Kms
D->B 334 Kms
Bananas at point C = 335
Bananas at point D = 0
Bananas at point B = 333
Did you notice
From point A to point C we have to travel 333*5 Kms (A->C, C->A, A->C, C->A, A->C)
From point C to pint D we have to travel 333*3 Kms (C->D, D->C, C->D)
From point D to pont B we have to travel 334*1 Kms (D->B)
Approach toward solution
To reach with maximum bananas to point B we should have to travel less because travel cost you one banana per km. We have to find point C and D such that distance between A to C is less and distanace between D to B is more.
Let's move step by step. One kms in one time. From point A to one km towards B and store 998 banans at this place and come back to point A to move next 1000 banans. This way we can move 998+998+999(3000-5) bananas. This process we have ro repeat till we have left with 2000 bananas. So we can travel 200 Kms from point A towards B by consuming 1000 bananas. so point C will be at 200 Kms from point A.
We reach point C with 2000 bananas.No we have to travel to point D. Our target to reach point D with 1000 bananas. We have to make 3 trips between point C and D to transport 2000 banans. So camel will consume 1000 bananas in 3 trips between C and D. D will be at distance 333.33 Kms from C. As we are not cutting any banana so let's put D at 333 Kms from C. Camel will consume 999 bananas between C and D and we will reach with 1001 bananas at point D.
Now we have to left one banana at point D. Sad but this we have to do to ensure that we do not make another trip. D is at 1000-200-333 = 467 Kms from B so camel will consume 467 bananas while travelling point D to B leaving us to transport 533(1000-467) bananas.
So the idea is find point C and D such that A to C camel will travel 5 times, C to D camel will travel 3 times and D to B camel will travel 1 time. We have to find C and D such that we can reduce the travel.
Solution
533 Bananas
Similar puzzle
What if distance from point A to point B is same 1000 kms but you have to transport 5000 banans. So in this case how much you can transport?
No comments:
Post a Comment