Friday 30 November, 2007

The CocoNut Problem

Five sailors survive a shipwreck and swim to a tiny island where there is nothing but a coconut tree and a monkey. The sailors gather all the coconuts and put them in a big pile under the tree. Exhausted, they agree to go to wait until the next morning to divide up the coconuts.

At one o'clock in the morning, the first sailor wakes up. He realizes that he can't trust the others, and decides to take his share now. He divides the coconuts into five equal piles, but there is one coconut left over. He gives that coconut to the monkey, hides his coconuts (one of the five piles), and puts the rest of the coconuts (the other four piles) back under the tree.

At two o'clock, the second sailor wakes up. Not realizing that the first sailor has already taken his share, he too divides the coconuts up into five piles, leaving one coconut over which he gives to the monkey. He then hides his share (one of the five piles), and puts the remainder (the other four piles) back under the tree. At three, four, and five o'clock in the morning, the third, fourth, and fifth sailors each wake up and carry out the same actions. In the morning, all the sailors wake up, and try to look innocent. No one makes a remark about the diminished pile of coconuts, and no one decides to be honest and admit that they've already taken their share. Instead, they divide the pile up into five piles, for the sixth time, and find that there is yet again one coconut left over, which they give to the monkey.

The Question: What is the smallest amount of coconuts that there could have been in the original pile?

You can also generalize the answer for n number of sailors by devising a C++ program.

4 comments:

"Sajal" said...

modify the problem to three sailors otherwise need for a computer program is necessary.

Mayank Gupta said...

for 3 sailors total no. of coconuts is 79 and each person in the end gets 7 coconuts.
congrats to sajal and sikhar who have done us all proud by gettng selected for ZIO...best of luck guys....i as usual have to fix my bad luck problems(not reading question......)

Mayank Gupta said...

why have i not got marks for this..............???????????

"Sajal" said...

You cant be given points for this stupid question