# 5 pirates and 1000 coins distribution || Interview Puzzle

This is one of the most important and interesting logical puzzles, since, the logic required to solve this puzzle may help in solving many other puzzles.

Puzzle Details ...

There are 5 pirates, A, B, C, D, and E. They have a strict hierarchy, A is senior to B, B is senior to C, C is senior to D and D is senior to E.

So it is like (A > B > C > D > E).
A’s age is greater than B
B’s age is greater than C
C’s age is greater than D
D’s age is greater than E

These pirates have 1000 gold coins which they want to distribute among themselves. The rules of distribution are as follows:

1. The most senior pirate proposes a distribution of coins.
2. The pirates, including the proposer, then vote on whether to accept this distribution. This means All the pirates (including the most senior) will vote on whether they accept the proposed distribution or not.
3. If the majority accepts the plan, the coins are distributed and the game ends. This implies that If half or more pirates vote in the favor of distribution, then the proposed distribution is accepted and the game ends.
4. If more than half the pirates vote against the distribution, then the senior most pirate will be killed and the next senior most will propose a new distribution and this will continue.
5. The process repeats until a plan is accepted or if there is one pirate left.
6. In case of a tie vote, the proposer has the casting vote. ( casting vote is a vote that someone may exercise to resolve a deadlock.)
These are distribution rules, and there are some rules followed by pirates also.

And These are the rules every pirate follows
1. First of all, each pirate wants to survive.
2. Second, given survival, each pirate wants to maximize the number of gold coins he gets.
3. Third, given a situation of no-gain no-loss, each pirate would prefer to kill the other pirate.
Considering that all pirates are very strong in logic, and if logic can be deduced, then they will deduce it. The problem statement is, How should A distribute the coins so that he does not get killed and also gets the maximum coins possible?

Take your time to solve this puzzle before checking the solution. Do not forget to Share your approach in the comment section.

Naturally, it may appear that A will have to give most of the coins (if not all) to the junior pirates so that his life can be saved. But that will not work. Because every pirate wants to maximize coins.

Suppose, If A decides to distribute 250 coins to each B, C, D, and E and keeps nothing for himself to get saved, then also he will be killed, because all others will vote against him, they can get the same distribution even if A is killed, and pirates want other pirates to be killed. This is because the next senior pirate may think that he will get more coins compared to the current distribution and hence disagrees. A similar thought process goes with every pirate and hence everyone disagrees with this logic because every pirate wants to maximize the number of coins.

So, finding a solution like this is very difficult. The solution to such puzzles can be easily found working in the bottom-up approach:

Let's go step by step.

1. Suppose if a number of pirates is 1, that is If there is just one pirate, say E then the distribution is very easy. He keeps everything to himself. This is the most ideal scenario.

E-1000

2. suppose If there are 2 pirates, say D and E (D senior to E), then D will distribute the coins like:
Pirate D can easily propose that he gets all the 1000 gold coins. Since he constitutes 50% of the pirates because there are only 2 pirates in this scenario, the proposal has to be accepted leaving Pirate E with nothing. Pirate E knows now, he gets noting if there are only 2 pirates left.

D-1000
E-0

Hence D will vote in favor of his distribution and the distribution will be accepted (because half people voted in favor).

3. suppose If there are 3 pirates, C, D, and E (C being the senior most), then C will make the following distribution: According to this distribution C gets 999 coins, D gets 0 coins and E gets 1 coin.

C-999
D-0
E-1

If there were three pirates, Pirate C needs one other person to vote for his plan. The trick to this puzzle is understanding that if Pirate C’s plan is voted down, he would die, and then there would be only two pirates on the boat. We already figured out what happens when there are only two pirates on the boat. In the case of two pirates, Pirate E receives nothing. So Pirate C can simply offer Pirate E a single gold coin and ensure his vote. As a perfectly rational pirate knows, one coin is better than no coins at all!

Now, C will obviously vote in favor. E knows that if C dies then D will make the next distribution and he will get nothing, hence E will also vote in favor (because they want to maximize their profit). And the distribution is accepted because more than 50% is voted in favor (that is 2 votes in comparison to 1 vote)

4. Suppose
there are 4 pirates, say B, C, D, E.
B being senior most, B will make the following distribution: According to the distribution B gets 999 coins, C gets 0 coins, D gets 1 coin and E gets 0 coins.

B-999
C-0
D-1
E-0

If there were four pirates, Pirate B needs to convince one other person to guarantee 50% of the vote. He could give Pirate E two gold coins, but his greed makes him realize that if his plan is destroyed, there will only be three pirates on the boat. When there are three pirates left, Pirate D knows he will get nothing; so Pirate B buys Pirate D’s vote with one gold coin.

Now, B and D will vote in favor of this distribution, because, If the distribution is not accepted and B dies, then C will have to make the distribution, and D will get nothing (you can see the distribution when there are 3 pirates ). Hence because 50% of pirates voted in favor of distribution, it will be accepted.

5. Finally, If there are 5 pirates, A, B, C, D, and E. A being the senior, A will make the following distribution: According to the distribution A gets 998 coins, B and D gets 0coin, and C and E get 1 coin.

A-998
B-0
C-1
D-0
E-1

when there are five pirates, Pirate A needs two other associates. He realizes that if he dies, Pirate C and Pirate E will get zero gold. So he offers each of them one gold coin and makes off with the other 998 gold coins.

By the same logic, A, C and E will vote in favor of the distribution and hence the distribution will be accepted.

This is the final distribution logic made by A. This is how A distributes the coins so that he does not get killed and also gets the maximum coins possible.

This question can be tweaked to confuse, if you know the logic then any tweaks to the original puzzle can be analyzed in the right direction.

Now if the question is asked for 6 pirates, then you can answer similarly. In fact, we can find the solution for any number of pirates.

In the same puzzle, Suppose there are 100 coins and 15 pirates, How does the most senior pirate save his life and gets as many coins for himself as possible?
Let me explain now

For a larger number, a pattern looks like this, and let's analyze the pattern:

No of Pirates(n)      No of coins got by each (nth, n-1th ... )
1                                          100
2                                       100, 0
3                                     99, 0, 1
4                                  99, 0, 1, 0
5                               98, 0, 1, 0, 1
6                            98, 0, 1, 0, 1, 0
7                         97, 0, 1, 0, 1, 0, 1

1) If there were only one pirate, he would keep all the gold for himself.

2) If there were two junior most pirates, the senior one would keep all the gold for himself and his junior would have to agree because the senior's vote would make 50% of the vote as discussed earlier.

3) If there were 3 pirates, then the senior most of these, the 3rd pirate gets to make the decision. He knows that if he is killed, the junior most would get nothing. So he gives one coin to him and gets his vote to make more than 50% vote. that is He keeps 99 for himself and gives 0 to the 2nd one and gives one coin for 1st once.

4) For 4 pirates case, 4th pirate knows the situations earlier that is for 3 pirates case.
He knows that the best junior-most traitor can get is 1 coin and the best 2nd pirate can get is 0 coins.
So if he gives just 1 coin to the 2nd pirate, then 2nd one would always agree. So he keeps 99 for himself, gives zero to the 3rd and 1st pirate, and 1 coin to the 2nd pirate.
This gets him 50% votes and he wins.

5) Now coming to 5th pirate (huff !)
He has his own vote on whatever decision he makes and needs two more votes. He knows that in case of his death, 1st and 3rd would get nothing. So he buys their vote by offering them 1 coin each and keeps 98 for himself. This means that to get the 50% votes, the senior pirate needs to give (n-1)/2 coins to his juniors where n is a number of pirates.

So 15th pirate would get 100-(15-1)/2 = 100-7 = 93 coins.
And from the pattern, the 14th pirate would not get any coin.
13, 11, 9, 7, 5, 3, and 1st pirates would get 1 coin each.