Planet

The Coconuts #2

At night on an Abakos beach, five sailors sleep next to a pile of coconuts, while one sneaks up on it and a monkey watches

This time the teleporter didn’t even try: Kinesys is back on the same little island on Abakos, just on a different beach. Here five sailors, also shipwrecked, are sound asleep next to a big pile of coconuts, guarded by a very alert monkey.

During the night, the crew witnesses a curious spectacle: one after another, the sailors wake up, fiddle with the coconuts, and go back to sleep. Dord is outraged by all the secrecy. Liz, who can’t sleep, dances on the sand by the light of Abakos’s moons. M00N, meanwhile, happily counts everything: on this planet, after all, it’s mandatory.

The Riddle

Five sailors and a monkey were shipwrecked on a desert island and spent the first day gathering coconuts. Then they piled them all together and went to sleep.

While everyone was asleep, one of them woke up and, figuring there would be arguments over the split in the morning, decided to take his share. He divided the coconuts into five equal piles: one coconut was left over, and he gave it to the monkey. Then he hid his share and put the rest back together. Soon afterward a second sailor woke up and did the same thing, also giving the leftover coconut to the monkey. One after another, all five sailors did likewise, each taking a fifth of the pile he found and giving one coconut to the monkey.

In the morning they divided the remaining coconuts, and each got the same number (this time with none left over). Of course, each of them knew some coconuts were missing, but each was as guilty as the others, so nobody said a word.

What is the smallest number of coconuts there could have been at the start? And what if there were N sailors?

Hint

Write one equation for each sailor: every number involved must be a whole number. There’s an elegant trick: add a few “borrowed” coconuts to the pile, always the same ones, so that the five nighttime divisions come out exact; then impose the morning split as a separate condition.

Solution

The answer is 3,121 coconuts.

Actually, the answer isn’t unique: once you know one solution, you get the others by adding (or subtracting) multiples of a constant, which in this case is 56 = 15,625. 3,121 is the smallest number of coconuts.

To find this value, you can solve the following system:

Y = 5 × A + 1
4 × A = 5 × B + 1
4 × B = 5 × C + 1
4 × C = 5 × D + 1
4 × D = 5 × E + 1
4 × E = 5 × F

where Y is the total number of coconuts at the start; A, B, C, D, and E are the coconuts taken by each sailor during the night; F is the number of coconuts each sailor gets in the morning split; and the +1 is the coconut given to the monkey each time. All these values must be whole numbers.

A few simple substitutions give:

1,024 × Y = 15,625 × F + 8,404

Now you have to solve this equation, keeping in mind that the results must be whole numbers. You can proceed by trial and error, but there are precise methods: for example, you can turn it into an integer linear programming problem, where the equation above is a constraint and the objective function to minimize is simply Y. This gives the solution 3,121 (with A = 624, B = 499, C = 399, D = 319, E = 255, and F = 204).

In the general case of N sailors, the solution is:

  • for odd N: (1 + N × K) × NN − (N − 1)
  • for even N: (N − 1 + N × K) × NN − (N − 1)

where K is a whole number (K = 0 gives the smallest value).

For a more thorough treatment, it’s worth reading Martin Gardner’s Mathematical Puzzles and Diversions, which devotes an entire chapter to this puzzle.

Source: Martin Gardner, Mathematical Puzzles and Diversions (Italian edition: “Enigmi e giochi matematici”)