Seems I have been too frequent in posting on my blog now a days. Thanks to my friends Sanjeet, Pranjal, Ashok ... with whom I discuss interesting problems. Just like my previous post, this post is also regarding a technical interview question asked in some company. Anyways, coming directly to the point.
There are five thieves T1, T2, T3, T4 and T5. They robbed 100 gold bars from a bank. For dividing the gold bars they came up with following idea.
- Starting from T5 to T1, a thief T_i will come up with a scheme to divide the gold bars amongst the thieves.
- Voting will happen in favour or against this scheme. If Majority ( Strictly greater than 50 % ) votes in favour then the division will happen according to the scheme. If not, then T_i will be killed and it will be T_i-1's turn to come up with a scheme.
Please keep in mind that
1) All thieves are intelligent.
2) All are very greedy, so they would try to get as much wealth as possible.
3) They all would like to kill as many thieves as possible. Of course, this motive stands at a lower priority level as compared to their greed for the gold.
If you are T5, what scheme would you come up with? Obviously, your motive would be to survive but try to come up with a scheme where you will get away with as much gold as possible.
PS:- Smallest unit of division is a gold bar. A bar can not be further divided.
The answer is that if you are T5, you can get away with as much as 97 gold bars and still survive!!! Puzzled!! Read further to discover how.
Let's try to situation one by one from thieves perspective.
If T1 is the only person left, he will take all the gold bars.
If T1 and T2 are the only persons alive, no matter what scheme T2 comes up with, he is going to be killed and T1 would take everything. Because T2 can not get the majority ( > 50% ). Obviously, T2 would do anything to keep T3 alive.
T3 knows that T2 is going to support him no matter what scheme he comes up with. T3 can take away all 100 gold bars as he will have the majority no matter what. ( T3+T2 = 66% votes ). Obviously, T3 would like T4 to get killed so that he can take everything.
T4 knows that T3 would want him to be killed. If T4 is killed, T1 and T2 would not get anything. So T4 would give one gold bar to T1 and T2 each. Now, T4 will get the majority ( T1 + T2 + T4 = 75%) and he can take as much as 98 gold bars.
You are T5. If you get killed, you know that T3 would not get anything. So to take T3 into confidence you will give him a gold bar. If you get killed, T1 and T2 each get a gold bar. As you want to optimize the amount that you can get away with, you would give one of T1 or T2 2-gold bars. You can get away with as much as 97 gold bars!!!