The camel and 3,000 bananas
product-puzzle case · difficulty 4/5 · 15 minutes · other
Prompt
A camel has 3,000 bananas and needs to cross a 1,000-mile desert to reach the market. It can carry at most 1,000 bananas at a time and eats one banana for every mile it walks. What is the largest number of bananas it can bring to the market?
Context
A classic interview puzzle. Core idea: Optimizing cache points (miles 200 and 533) to maximize forward transport. Talk through your reasoning; the interviewer cares as much about structure as about the answer.
Clarifying questions
- Can it drop bananas?
- Yes, it can drop bananas anywhere and return to the start, always eating one banana per mile walked, and it can carry at most 1,000 at a time.
Recommendation
**Answer:** About 533 bananas (533 1/3 if the distances can be fractions of a mile). Caches at mile 200 and mile 533. **Why:** Each stage reduces the number of loads by one, so the camel only pays the expensive 5-bananas-per-mile rate for as short a distance as possible.
Risks
- Carrying 1,000 bananas in one trip and arriving with none
- Making the first stage too long or too short so that the camel carries more than 1,000 or leaves bananas behind
Next steps
- Find the maximum distance with 3,000 bananas (1,533 miles)
- Change the capacity to 500 bananas and recompute