A farmer has 3000 apples, he wants to deliver them to a market that is 1000 miles away through the desert. He has a camel which can carry only 1000 apples at a time but also has to eat one apple for each mile of walking. What is the maximum amount of apples that can be delivered and how?

Warning: Use of undefined constant bfa_comments - assumed 'bfa_comments' (this will throw an Error in a future version of PHP) in/home/customer/www/riddledude.com/public_html/wp-content/themes/atahualpa/comments.phpon line132one

No, that’s not it, keep guessing.

2000 because the horse would need to eat the 1st 1000 getting there

Wrong! Keep in mind the horse can only carry 1000 at a time.

Here’s a hint: Since the horse can only carry 1000 at a time, and he would eat 1000 getting there, the trip would have to be completed in segments.

Keep guessing.

1000, horse would need to eat 1000 apples to reach at the desire place and another 1000 apples for the return journey…hence maximum amount of apples that can be delivered is 1000

No, that’s incorrect.

Once again, the trip must be made in segments, and you need not concern yourself with the return trip.

Keep guessing, jeep those juices flowing!

500 apples

500 is correct, but we also want to know how.

500, here’s how I guess it would be:

The camel carries 1000 apples (leaving 2000 at starting point) and walks the first 250 miles. The farmer must leave 500 apples on the 250th mile. The camel walks back home eating all the 250 apples left.

The camel carries the next 1000 apples (leaving 1000 at starting point) to the 250th mile. The camel has 750 left and picks up the 250 of the 500 he left, so now has 1000. He walks from the 250th mile towards the 500th mile. Walking 250 miles, now has 750 left. He leaves 250 of them on the 500th mile. Then he goes back with 500 apples for his 500 mile trip from the 500th mile to the starting point.

He carries all 1000 left apples. On the 250th mile, he eats 250 and replenishes 250 that were left from a while ago. On the 500th mile, he eats 250 more but gains another 250. It is now at the 500th mile with 1000 apples. It walks to the market and still has 500 left.

That is how he could deliver 500 apples! :)

Yaay! Can’t believe I actually solved it :D

500 apples is correct!

Here is how the RiddleDude figured it:

He can get 500 across for sure. Here’s how:

Assume points A are start (3000 apples) and B finish (0 apples initially).

Distance between A and B is 1000 miles.

Two camps needed:

Camp 1 – 250 miles from A, 750 miles from B.

Camp 2 – 500 miles from A, 500 miles from B.

Trip 1 A-Camp 1 and back

Take 1000 apples, go to camp 1. 250 are eaten along, drop 500 at camp 1, eat 250 while going back to A.

Stores: A(2000), Camp1(500), Camp2(0), B(0)

Trip 2 A-Camp 1 and back

Take 1000 apples, go to camp 1. 250 are eaten along, drop 500 at camp 1, eat 250 while going back to A.

Stores: A(1000), Camp1(1000), Camp2(0), B(0)

Trip 3 A-Camp 1

Take 1000 apples, go to camp 1. 250 are eaten along,

Stores: A(0), Camp1(1750), Camp2(0), B(0)

Trip 4 Camp 1-Camp 2 and back

Take 1000 apples from Camp1, go to camp 2. 250 are eaten along, drop 500 at destination, eat 250 on the way back to camp 1.

Stores: A(0), Camp1(750), Camp2(500), B(0)

Trip 5 Camp 1-Camp 2

Take 750 apples from Camp1, go to camp 2. 250 are eaten along, drop 500 at destination.

Stores: A(0), Camp1(0), Camp2(1000), B(0)

Trip 6 Camp 2-B

Take 100 apples from Camp2, go to B. 500 are eaten along, drop 500 at destination.

Stores: A(0), Camp1(0), Camp2(0), B(500)

Great job, Tiffy. You’re today’s winner.

:D Hooray!

I get 833 apples. the key is to arrive at the depot 1, 2, or 3000 apples. 3000 is impossible. 2000 means three trrips of 334 (rounding up when dividing 1000/3.) To have exactly 1000, the maximum lod per trip, make two trip tpo the depot each being 499 miles. Nothe that each trip require 999 apples, again the maximum load for a trip and that’s what you want. Easy to see the intial tripsare 334 miles each.

I cannot general my solution nor come up with a neater proof that mine is best. Any suggestions?

1000-500 miles*3 times=1500 apples

then 1000-250 miles=750 apples

and 500-250=250 apples

total=750+250=1000 distance reached 750 miles

now 1000-250= 750 reached destination

so its 750 That’s all i can try for now :)

Right ans is 533…

$ cat GC83DPP.sh

awk '

function market(apples, mileage) {

trips = apples/1000*2-1

left = mileage

while (trips > 1)

{

this = 1000 / trips

left -= this

trips = trips - 2

}

return 1000-left;

}

BEGIN {

print "3000 apples in 1000 miles", market(3000, 1000)

print "5000 apples in 1500 miles", market(5000, 1500)

}'

`$ sh GC83DPP.sh`

3000 apples in 1000 miles 533.333

5000 apples in 1500 miles 287.302

Rick, your code is brilliant!