十七头骆驼以及它们能带你去的地方
Seventeen Camels and Where They Can Take You

原始链接: https://mathenchant.wordpress.com/2026/06/15/seventeen-camels-and-where-they-can-take-you/

这六个数学谜题各不相同,涵盖了遗产纠纷、椰子分配、图论以及洗牌等多个领域,但它们都共享一个优雅的共同策略。这些问题乍看之下似乎难以解决,甚至无法实现,但只要引入一个看似无关的“催化剂”元素,就能迎刃而解。 正如经典的“17只骆驼”谜题一样——通过临时借入第18只骆驼简化遗产分配计算,最后再将其取回——这些解决方案都依赖于添加一个辅助对象来平衡数学关系。无论是向一副牌中加入一张小丑牌、在天平上放置一枚“已知重量”的硬币,还是在森林的树木之间架设一座虚构的桥梁,这些添加的组件都能简化逻辑,并在目标达成后随之消失。 这种“添加元素以满足约束、解决问题,最后舍弃辅助”的原则,是一种强大的启发式思维。这些谜题展示了创造性思维如何通过暂时扩展系统,将复杂且陷入僵局的场景转化为简单直观的问题,从而达到优雅的解决方案。

Hacker News | 最新 | 过往 | 评论 | 提问 | 展示 | 招聘 | 提交 | 登录 十七头骆驼与它们能带你去的地方 (mathenchant.wordpress.com) 9 分,由 ibobev 发布于 1 小时前 | 隐藏 | 过往 | 收藏 | 1 条评论 | 帮助 jmilloy 8 分钟前 [–] 我只看了第一个“谜题”,然后带着某种挫败感回到了这里。这个“解决方案”包括把 9 头骆驼分配给大儿子,但 9 并不是 17 的 1/2。也许我太迂腐了,但如果解决方案允许近似或更改分配比例,那么应该在题目描述中说明!我觉得被骗了。还有其他人吗? 回复 指南 | 常见问题 | 列表 | API | 安全 | 法律 | 加入 YC | 联系 搜索:
相关文章

原文


“Oh, it’s just a trick thing.” – Ben Ames Williams, Coconuts

Here are six puzzles, some of them classics, that don’t look much alike on the surface. After stating them, I’ll give a hint about what they have in common. Then I’ll present solutions that all make use of the same slick trick in one form or another.

Puzzle 1: A wealthy merchant died, leaving seventeen camels to be distributed among three heirs. The merchant’s will stipulated that one half of the camels should go to the eldest heir, one third of the camels should go to the second heir, and one ninth of the camels should go to the youngest heir. The most literal-minded course of action would be to butcher some of the camels, giving eight-and-a-half camels to the eldest heir, five-and-two-thirds camels to the second heir, and one-and-eight-ninths camels to the youngest heir, with the remaining one-eighteenth of a camel left for the vultures. But surely the merchant hadn’t intended such carnage! While they were puzzling over their situation, a passing trader stopped to ask what the problem was. When they explained the impasse they were facing, the trader solved their problem with one simple suggestion. What was it?

Puzzle 2: Five sailors and a monkey were shipwrecked on a desert island. The sailors spent the first day gathering coconuts for food; then they piled all the coconuts together and went to sleep for the night. One sailor woke up and decided to take a fifth of the coconuts while the others slept. The sailor divided the coconuts into five piles with one coconut left over, then hid one of the piles, merged the other four piles, and gave the extra coconut to the monkey. One after another, the other four sailors did the same thing, each one dividing the current pile into five equal piles with one coconut left over, hiding one pile, merging the other four piles, and giving the leftover coconut to the monkey. In the morning the five sailors divided what coconuts were left, and the coconuts came out in five equal shares with none left over. How many coconuts were there in the beginning? (There are actually infinitely many possible answers to the problem; so the question really asks, What’s the smallest possible number of coconuts in the original pile, if we take the story to be true?)

If that’s too hard to tackle straight off, here’s a warm-up to get you in the right frame of mind: what’s the smallest positive integer that leaves remainder 2 when divided by 3, remainder 4 when divided by 5, and remainder 6 when divided by 7?

Puzzle 3: Suppose your Introduction to Discrete Mathematics teacher taught you a formula that you don’t remember how to prove, involving concepts from graph theory. A graph is a collection of dots (called vertices) together with some line segments or curves (called edges) that connect one vertex to another; we’ll assume there are only finitely many vertices and edges. A graph is said to be connected if there’s a way to travel from any vertex to any other vertex along a path that uses edges of the graph. A cycle in a graph is a path in the graph that starts at a vertex, travels along an edge, then travels along another edge, and so on, eventually returning to the original vertex without reusing any edges. Finally, a connected graph is called a tree if it contains no cycles. For instance, the graph shown here is not connected because there is no path from vertex a to vertex d; neither is the graph free of cycles because there is a cycle composed of the edge from a to b, the edge from b to c, and the edge from c to a.

The teacher’s formula, E = V−1, says that the number of edges in a finite tree is always 1 less than the number of vertices. So for instance in the tree shown in the picture below we see 10 vertices and 9 edges.

The trouble is, you’re taking the midterm exam and the teacher has asked you about forests. You remember that a forest is just like a tree except that it doesn’t have to be connected – it’s only required to be free of cycles. So every tree is a forest, but a forest could consist of two trees, or three trees, or even more. The exam problem says: “Suppose the graph G is a forest consisting of two trees. Suppose also that G has ten vertices. How many edges does G have?” Your cheat sheet has the formula E = V−1 but that only works for trees; it doesn’t apply to forests in general. What do you do?

Puzzle 4: Suppose you have 4 suspect coins, 1 of which is counterfeit (either heavy or light). You also have a pan balance scale. Is it possible in just two weighings to find the bad coin and to determine whether it is heavy or light? If not, what simple additional object would enable you to do it?

Puzzle 5: If you deal out the 52 cards in a randomly-shuffled deck until you find one of the 4 jacks and then stop, how many cards should you expect to have to deal on average?

Puzzle 6: Given a deck of cards numbered 1 through N (with N > 1), not necessarily arranged in order, we define a grand swap as the following N-step procedure: swap the part of the deck that’s above the 1 with the part that’s below the 1; then swap the part of the deck that’s above the 2 with the part that’s below the 2; and continue in this manner, until finally you swap the part of the deck that’s above the N with the part that’s below the N. If one of the “parts” that you’re trying to swap is empty, the swap is equivalent to simply moving the top card to the bottom or vice versa.

For example, suppose we start with 1, 2, 4, 3, with 1 on the top and 3 on the bottom. We swap the cards above the 1 (“all zero of them”!) with the cards below the 1 (all three of them) to get 2, 4, 3, 1. Then we swap the cards above the 2 with the cards below the 2 to get 4, 3, 1, 2. Then we swap the card above the 3 with the cards below the 3 to get 1, 2, 3, 4 (notice that the 1 and the 2 remain in the order they were in before; though two piles are swapped, each pile stays in its original order). Finally we swap the cards above the 4 with the cards below the 4 to get 4, 1, 2, 3. So, our grand swap sends 1, 2, 4, 3 to 4, 1, 2, 3.

Show that performing N+1 successive grand swaps always brings the deck back to its original order.

* * * * * * * * * * * * * * * * *

HINT

In all these puzzles, there’s an elegant solution in which you add a seemingly extraneous element that can subsequently be discarded.

As an example of adding something to a problem to make it simpler, consider the warm-up puzzle proposed at the end of Puzzle 2 (“What’s the smallest positive integer that leaves remainder 2 when divided by 3, remainder 4 when divided by 5, and remainder 6 when divided by 7?”); call the mystery number N. Since N leaves remainder 2 when divided by 3, N+1 must be exactly divisible by 3. Likewise N+1 must be exactly divisible by 5 and by 7, and since the numbers 3, 5, and 7 are relatively prime (that is, they have no factors in common bigger than 1), N+1 must be divisible by 3 × 5 × 7 = 105. So the answer to the warm-up puzzle is

(N+1) − 1 = 105 − 1 = 104.

For more examples of this “camel trick” in mathematics see the MathOverflow post The 17 camels trick and Tivadar Danka’s blog post The camel principle.

* * * * * * * * * * * * * * * * *

SOLUTION TO PUZZLE 1

The trader says “Borrow my camel!” Now there are 18 camels. The first heir receives one half of 18, or 9, camels; the second heir receives one third of 18, or 6, camels; and the third heir receives one ninth of 18, or 2, camels. This accounts for 9+6+2 = 17 camels. If the apportioning is done in a manner sensitive to the animals’ needs for familiar faces, these 17 camels will be precisely the deceased merchant’s camels, and the trader can ride off on the camel that was lent to the heirs.

This may seem like a purely recreational puzzle, but when seats in a governing body are apportioned based on population counts, one can face similar issues. In those situations, the relevant fractions (1/2, 1/3, and 1/9 in our puzzle) typically add up to 1, but there’s still a thorny problem to be solved if those fractions, when multiplied by the total population, fail to yield whole numbers. An analogous problem of a camelid kind would be: how can three heirs receive 1/2, 1/3, and 1/6 of the merchant’s camels if the total number of camels is 17? Clearly the apportionment can’t be done exactly if we don’t butcher any camels, but how close can we get? And what does “close” even mean in this context? There are many approaches to dealing with this kind of problem; to see how the U.S. handles it, see the Census Bureau post on Methods of Apportionment.

In an alternate version of the puzzle in which the fractions add up to more than 1 rather than less than 1, the trader can help the heirs by stealing a camel and then returning it!

SOLUTION TO PUZZLE 2

Let N be the number of coconuts in the original pile. Imagine an alternate scenario in which the monkey has four coconuts of her own at the start (suppose that they’re blue) and she adds them to the pile, so now there are N ordinary coconuts and 4 blue ones, for a total of N+4. The first sailor to wake will discover that the pile is evenly divisible by five. The sailor divides the big pile into five equal smaller piles. Since there are only four blue coconuts, at least one of the five piles contains none of them. The sailor takes such a pile and hides it, gives one of its coconuts to the monkey, and puts the other four small piles (which collectively contain all four blue coconuts) back together into one big pile. Each sailor does the same thing. During the final division in the morning, the four blue coconuts are left on the side; the monkey reclaims them. Since the augmented pile (with the blue coconuts included) was evenly divided into fifths five times during the night, it must have contained 55 = 3125 coconuts or some multiple thereof when the sailors went to bed. So the smallest consistent answer N satisfies N+4 = 3125, giving N = 3121.

One can also have a bogus answer in which there are −4 coconuts at the start. If one allows negative coconuts, then the algebraic solutions are precisely the numbers of the form −4 plus a multiple of 3125; the smallest non-bogus answer is −4 + 3125 = 3121.

SOLUTION TO PUZZLE 3

Add an edge joining a vertex in one tree to a vertex in the other tree. Now your two-tree forest has become a single tree on ten vertices, so the teacher’s formula applies: the number of edges is 10−1, or 9. But remember, one of those edges is the extra edge that you added; if you erase it, the number of remaining edges will be 9−1, or 8. In fact, it can be shown that a forest on n vertices that consists of t trees must have nt edges.

If you’re wondering why adding that new edge turned the two-tree forest into a single tree, note that the added edge that joins the first tree (call it T1) to the second tree (call it T2) cannot create a cycle, because if there were a cycle, it would have to cross from T1 to T2 along some edge and then from T2 back to T1 along some other edge, and there’s only one edge between T1 and T2. On the other hand, the new graph is certainly connected, and since we just learned that it’s free of cycles, it’s a tree.

SOLUTION TO PUZZLE 4

You should ask for a known good coin. Call the original coins A, B, C, and D and the known good coin G. The eight possibilities you must discriminate between are A− (A is the bad coin and is light), A+ (A is the bad coin and is heavy), B−, B+, C−, C+, D− and D+.

On the first weighing, weigh A and B against C and G. There are three cases.

1. If the two pans balance, D is the bad coin. Weighing D against G on the second weighing will distinguish the cases D− and D+ from each other.

2. If the left pan is heavy, the possibilities are A+, B+, and C−. Weigh A against B. If they balance, deduce C−; otherwise, we can distinguish between A+ and B+.

3. If the right pan is heavy, the possibilities are A−, B−, and C+. Weigh A against B. If they balance, deduce C+; otherwise, we can distinguish between A− and B−.

In all three cases, one determines the bad coin and determines whether it is heavy or light.

On the other hand, without the known good coin, the puzzle can’t be solved. To see why, consider the two possible ways the weighing protocol could begin.

Case 1. If the first weighing weighs all four coins, then there are only two possible outcomes (the two pans can’t balance since one coin is bad), and in each of the two outcomes, there are four possibilities that we must discriminate among using only a single weighing; but this can’t be done, since the weighing has only three possible outcomes (left goes down, right goes down, both sides balance).

Case 2. If the first weighing weighs just two coins, say A against B, then in the case in which the two coins balance, there are again four possibilities (C+, C−, D+, and D−) that we must discriminate among in just one weighing, which again can’t be done.

SOLUTION TO PUZZLE 5

Given a randomly-shuffled deck—that is, a deck that has an equal chance of the cards being in each of the astronomically-many possible orders—imagine including a joker at a random position in the deck and fanning out the cards in a circle. The jacks and the joker divide the deck into five segments, and by symmetry each of the 48 non-jack-non-joker cards has no reason to prefer one segment over another; each segment will on average consist of 48/5 such cards. Now remove the joker and arrange the cards in a line, starting with the card just clockwise from the joker and ending with the card just counterclockwise from the joker. It’s still the case that each segment will on average have 48/5 = 9.6 non-jack cards. So if we play the find-the-first-jack game with this new arrangement of the cards, we expect to deal out 9.6 + 1 = 10.6 cards.

But wait a minute: The process we followed in creating this line of cards doesn’t really require us to put the cards in a circle; it’s enough to insert a joker in a random location in the original deck, put the cards below the joker above the joker, and remove the joker. Simpler still, we can just cut the deck at a random position; there’s no need to involve a joker at all.

Now, a randomly-shuffled deck that gets cut in a random location is still a randomly-shuffled deck. So the question “If you deal out the cards in a randomly-shuffled deck until you find one of the jacks, how many cards should you expect to have to deal?” and the question “If you cut a randomly-shuffled deck at a random position and then deal out the cards in until you find one of the jacks, how many cards should you expect to have to deal?” must have the same answer.

Since the answer to the second question is 10.6, that must also be the answer to the original question!

If you’re comfortable with the concept of linearity of expectation, there’s another way to derive the answer that you may prefer. The number of non-jack cards that precede the first jack can be written as a sum of 48 numbers, each of which is 0 or 1: the number of aces-of-spades that precede the first jack, the number of kings-of-spades that precede the first jack, the number of queens-of-spades that precede the first jack, and so on, down to the number of twos-of-clubs that precede the first jack. The principle of linearity of expectation says that the expected value of the sum of those 48 numbers is equal to the sum of the expected values of those 48 numbers. This seems like a horrible approach until you stop to consider that each of those 48 numbers has expected value 1/5. Why? Well, let’s focus on the ace of spades, since the argument applies to each specific kind of card in the same way. The number of aces-of-spades that precede the first jack is equal to 1 if the ace of spades precedes all four of the jacks and is equal to 0 otherwise. The probability that the ace of spades precedes the jack of spades, the jack of hearts, the jack of diamonds, and the jack of clubs when all 52 cards are dealt is 1/5 by symmetry (the identities of the five cards are irrelevant). So the number of aces-of-spades that precede the first jack is equal to 1 one-fifth of the time and is equal to 0 four-fifths of the time, giving it an expected value of 1/5. Lik wise for each of the other 47 non-jack cards. Hence the expected number of non-jack cards that precede the first jack in the original problem is 1/5 + 1/5 + 1/5 + ⋅ ⋅ ⋅ + 1/5 = 48/5 = 9.6, and adding 1 for the jack itself gives 10.6 as before.

SOLUTION TO PUZZLE 6

Add an imaginary card to the deck, numbered 0. We can now represent the order of cards in the deck by a circular arrangement of 0, 1, . . . , N (to be read clockwise, let’s say), where 0 marks the beginning/end of the deck. For example, the arrangement

would represent a 7-card deck in the order 2, 5, 1, 4, 3, 7, 6. Note that rotating the circle does not make any difference in terms of the associated linear ordering of the deck, which begins just clockwise from the 0 and ends just counterclockwise from the 0 (this should remind you of the joker from the previous problem). All that matters is the clockwise cyclic ordering of the numbers 0 through N.

When we swap the part of the deck above k with the part below k, the effect on the circular arrangement is to swap the two arcs delimited by 0 and k (here I take k=1):

But that new cyclic order shown on the right can be achieved more simply by just swapping the 0 and the k themselves:

Thus, a grand swap swaps 0 with 1, then 0 with 2, then 0 with 3, . . . , and finally 0 with N.

Tracking each card’s label throughout this process, we have

0 → 1,
1 → 0 → 2,
2 → 0 → 3,
3 → 0 → 4,
. . .
N−1 → 0 → N , and
N → 0.

Thus, the effect on each number in the circle is to increment it by 1 with N wrapping around to 0. When we repeat this operation N+1 times, every number in the circle cycles back to its original value, and the original order of the deck is restored.

* * * * * * * * * * * * * * * * *

In each of these stories, the extra object behaves like a catalyst, or like the Lone Ranger from the classic radio and television series, departing as mysteriously as he arrived once the afflicted town has been saved (“Who was that masked man?”). The trader rides away on his camel; the monkey reclaims her blue coconuts; the added edge is erased; the known good coin returns to your pocket; the joker is removed from the deck; and the imaginary card numbered 0 vanishes, or rather, was never there to begin with. Yet without that extra object, the elegant solution would not have been possible.

ENDNOTES

1. The earliest documented appearance of this classic puzzle occurs in the work of the 18th-century Shiite Iranian philosopher Mulla Muhammad Mahdi Naraqi. Many variants exist; see the 17-animal inheritance puzzle Wikipedia page.

2. Problems of this kind seem to have first been introduced to the mathematical literature in the Ganita-sara-sangraha (“Compendium of the Essence of Mathematics”) of the Indian mathematician Mahāvīra, circa 850CE; his versions dealt with serial division of fruit and flowers. The version I give here is very close to the version that the American author Ben Ames Williams used in his 1926 short story Coconuts, which appeared in the October 9, 1926 issue of the Saturday Evening Post. The main character is a mathematically-inclined man named Wadlin who works for an architect. When Wadlin finds out that his boss may be outbid by a rival architect named Marr, Wadlin sneaks into Marr’s favorite restaurant, allows Marr to find him furiously calculating, and with feigned reluctance reveals what he’s working on — a math puzzle he says he learned earlier that day “from a man uptown”. This math puzzle is none other than the coconuts problem. The bait has the desired effect: the nerd-sniped Marr becomes obsessed with the puzzle and misses the bidding deadline.

Ironically, many readers of the Post found themselves in Marr’s position, as Williams had neglected to include the answer to the puzzle in his story. This omission led over two thousand angry readers to write to the Post demanding that it provide the answer. The editor of the Post had to send an urgent telegram to the author, demanding “FOR THE LOVE OF MIKE, HOW MANY COCONUTS? HELL POPPING AROUND HERE”.

It’s possible that the young Martin Gardner got wind of the fracas; he was twelve at the time. In any case, he went on to found and run the Mathematical Games column at Scientific American in 1957, and he shared the coconuts puzzle with his readers in 1958. He went on to publish many other puzzles during his thirty-year stint running the column, but he once told his son Jim that the problem of the coconuts was his favorite.

For more about the problem, see the Wikipedia page The monkey and the coconuts.

3. This is an actual problem I gave my students on a midterm exam earlier this year. A few students gave the camel solution. More students used a divide-and-conquer approach, applying the E = V−1 formula to each of the two trees: if the first tree has m vertices and the second has n vertices, then the total number of edges in the forest must be

(m−1) + (n−1) = (m+n) − 2 = 10 − 2 = 8.

The divide-and-conquer argument is arguably more straightforward, but the camel argument is what earned the problem a place in this essay.

4. There is a huge literature on coin-weighing problems. Here is a classic without the extra wrinkle of a known good coin: You have 12 seemingly identical coins. One of them is counterfeit but you do not know if it is lighter or heavier than the genuine ones. You have exactly 3 uses of a pan balance to find the bad coin and to determine if it’s heavy or light. If you are content with just finding the identity of the counterfeit coin and not necessarily knowing whether it’s heavy or light, you can actually replace 12 coins by 13 coins. See the Balance puzzle Wikipedia page.

5. I learned about this problem from Peter Winkler; it appears in chapter 8 of his book Mathematical Puzzles.

6. This is a problem that I came up with a few years ago and contributed to the 2026 Bay Area Mathematics Olympiad. The solution that appears above is a composite solution devised by me and the contest organizers.

7. It’s not a coincidence that I chose to publish these problems on or shortly before June 17, 2026; that’s the day on which dozens of people gathered at Hampshire College to celebrate the life and legacy of mathematician David Kelly (1940-2025), who could justly be described as a catalyst in the mathematical community; as Kelly explains in the documentary Hunting Yellow Pigs, his favorite way of teaching was to get students thinking about a juicy problem and then get out of their way. The number of camels in Naraqi’s puzzle was Kelly’s favorite number—seventeen.

联系我们 contact @ memedata.com