- Prepare
All Platforms Programming Aptitude Syllabus Interview Preparation Interview Exp. Off Campus - Prime Video
- Prime Mock

- Interview Experience
- Prime VideoNew
- Prime Mock
- Discussion Forum
- Nano Degree
- Prime Video
- Prime Mock

# Coin Puzzle 4

## Coin Puzzle 4

There are 5 pirates, they must decide how to distribute 100 gold coins among them. The pirates have seniority levels, the senior-most is A, then B, then C, then D, and finally the junior-most is E.

Rules of distribution are:

- The most senior pirate proposes a distribution of coins.
- All pirates vote on whether to accept the distribution.
- If the distribution is accepted, the coins are disbursed and the game ends.
- If not, the proposer is thrown and dies, and the next most senior pirate makes a new proposal to begin the system again.
- In case of a tie vote the proposer can has the casting vote

Rules every pirates follows.

- Every pirate wants to survive
- Given survival, each pirate wants to maximize the number of gold coins he receives.

**What is the maximum number of coins that pirate A might get?**

**Solution:**

To know what amount coins A might get we need to see all those cases where A dies:

**Case 1: **

- Let’s suppose a situation when A, B, and C died, such that D, and E are the only ones left. Now E knows that he will not get anything as D is senior and D will make a distribution of (100, 0). So E would be find with anything greater than 0.

```
Case 1: When A, B, and C dies and D, and E are left
Coins distribution in this case
A = 0 (as he is dead)
B = 0 (as he is dead)
C = 0 (as he is dead)
D = 100 (as now he is only senior)
E = 0 (as he is most junior)
```

In Case 1 distribution will be (100, 0) among D and E.

**Case 2: **

- Let’s suppose a situation when A, and B dies and C, D, and E are only left. Now D knows he will not get anything as C is senior than D and C will make a distribution of
**(99, 0, 1)**. Now in earlier case E was not getting anything and now he is getting 1 coin so he will not oppose this situation and E will vote in favor of C.

```
Case 2: When A, and B dies and C, D, and E are left
Coins distribution in this case
A = 0 (as he is dead)
B = 0 (as he is dead)
C = 99
D = 0
E = 1
```

In Case 2 distribution will be (99, 0, 1) among C, D and E.

**Case 3: **

- Let’s suppose a situation when only A dies and B, C, D, and E are left.

Now to survive B only needs to give 1 coin to D. So the distribution will be **(99, 0, 1, 0).**

```
Case 3: When A dies and B, C, D, and E are left
Coins distribution in this case
A = 0 (as he is dead)
B = 99
C = 0
D = 1
E = 0
```

In Case 3 distribution will be (99, 0, 1, 0) among B, C, D and E.

**Case 4:**

- Now, in similar manner when is alive he knows about Case 3, so he just need to give 1 coin to C and 1 coin to E to get them in favor. So, the distribution will be
**(98, 0, 1, 0, 1).**

The idea is based on the fact that what B will distribute if A dies (B would always want A to die). If A gives more coins to 2 people than B would have given, A wins.

```
Case 4: When all A, B, C, D, and E are alive
Coins distribution in this case
A = 98
B = 0
C = 1
D = 0
E = 1
```

In Case 4 distribution will be (98, 0, 1, 0, 1) among A, B, C, D and E.

Login/Signup to comment