Counting coconuts

This Riddler problem is about divisibility… of coconuts!

Seven pirates wash ashore on a deserted island after their ship sinks. In order to survive, they gather as many coconuts as they can find and throw them into a central pile. As the sun sets, they all go to sleep.

One pirate wakes up in the middle of the night. Being the greedy person he is, this pirate decides to take some coconuts from the pile and hide them for himself. As he approaches the pile, though, he notices a monkey watching him. To keep the monkey quiet, the pirate tosses it one coconut from the pile. He then divides the rest of the pile into seven equally sized bunches and hides one of the bunches in the bushes. Finally, he recombines the remaining coconuts into a single pile and goes back to sleep. (Note that individual coconuts are very hard, and therefore indivisible.)

Later that night, a second pirate wakes up with the same idea. She tosses the monkey one coconut from the central pile, divides the pile into seven bunches, hides her bunch, recombines the rest, and goes back to sleep. After that, a third pirate wakes up and does the same thing. Then a fourth. Then a fifth, and so on until all seven pirates have hidden a share of the coconuts.

In the morning, the pirates look at the remaining central pile and notice that it has gotten quite small. They decide to split the pile into seven equal bunches and take one bunch each. (Note: The monkey does not get one this time.) If there were N coconuts in the pile originally, what is the smallest possible value of N?

Here is a short solution:
[Show Solution]

If you’d like to learn more about how to solve such problems (what is modular arithmetic anyway!?) then read on!
[Show Solution]

6 thoughts on “Counting coconuts”

  1. Hi nice post as usual. In the general solution I think there is a problem in this step:

    “Reducing and rearranging this is equivalent to:

    160681 * k = 97590”

    The eventual correct result will (I think) look like N^N * k – (N-1); k={1,..} or in this case:
    823543 * k -6 ; k={1,…}

    1. Oops. Sorry. This is wrong. It doesn’t leave an integral numnber of coconuts per pirate at end, just an integral total number.

  2. Hi,

    This can be solved without modular arithmetic; just high school algebra (geometric progression) is sufficient. All we have to do is go backwards from the last count.

    Here is the solution:
    https://imgur.com/a/HV0UTod

    Vaidhy

    1. Just going through my solution again, it seems that there is a closed form solution if you take it further along.

      For n odd initial count = m(n^n – n + 1)
      For n even initial count = n^(n+1) – m (n^n+n-1)

      For m = 1, n = 7, count = 7^7 – 7 + 1 = 823,537

  3. In the related problem where the monkey gets [takes] a coconut each time, including the morning, then the “smallest” solution is N = -6. Each time during the night: The monkey takes a coconut, the pile becomes -6 – 1 = -7; the pirate takes 1/7 of the remaining pile: -7 – (-7 /7) = -7 – (-1) = -6. Taking -1 coconut is the same as giving +1 coconut: the pirate’s -1 coconut corresponds to the monkey’s +1 coconut, so coconuts balance. Furthermore, each pirate encounters the pile the same as when the pirates went to sleep (namely, -6 coconuts), so no one suspects anything! The “extra” coconut comes from the monkey, who withheld it from the original pile. But being a monkey, the monkey loses it each time, and the pirate finds it just soon enough to give it back to the monkey. The monkey is a [lossy] banker who facilitates each pirate’s greed by re-circulating the coconut.

    Exploration: Iterating f(M) = 6*(M -1)/7 must eventually produce a fixed point: f(M) = M. Solving 6*(M-1)/7 = M yields M = -6. That’s the same -6 as in Jim Crimmins’ comments above.

    Alternate approach to the related problem: Write all numbers in base 7, and work backwards. Then at each stage the least-significant digit must be 1; giving a coconut to the monkey makes the lowest digit zero: the pile becomes divisible by 7. Dividing by 7 is equivalent to shifting off the lowest digit. Taking 1/7 of the pile must leave a lowest digit of 1 for the next stage , so the lowest digit subtracted must be 6; the two lowest-order digits must be 61 (base 7). Continuing the analysis at each backward step shows that N = …666661 base 7, which is -6 (modulo any power of 7). The particular power is the number of instances at which the remaining pile is required to be a multiple of 7.

Leave a Reply

Your email address will not be published. Required fields are marked *