Two prisoners were sentenced to death by King Xuan of Zhou and were kept in two different inaccessible cells. They were to be put to the gallows the day after. However, King Xuan wanted to give them a last chance. Since he was very fond of riddles, he came up with one for the prisoners which if they solved, they would be set free. The prisoners were told that they would be put into a single cell for a day when they can discuss their strategy, after which they would again be sent back to their respective cells. One of the prisoners would then be given 5 playing cards out of the pack of 52 cards. He can send four of these five cards to the other prisoner through the jailor one by one after which the second prisoner has to guess the one card (number and suit) which is left with the first prisoner. If he guesses right, both the prisoners would be set free but if not they would be hanged the same day.
What strategy could they possibly come up with which could save them?
Link to the Solution
8 comments:
Simple. Bribe the fcuking guard.
@Vivek: What if the guard is not corrupt? :P
that's another question :P
Write another blog post over it :D
Simple. Since there are 5 cards, at least two will have to be of same suite. So I keep one of them and pass the other one as the first card. This way the second guy will know the suite.
With the three remaining cards that needs to be passed on, I will establish an absolute ordering between them (breaking ties on number based on suite). So lets call the largest card C3, the second largest C2 and smallest card C1. I can arrange these in 3! = 6 ways. I can use these to represent 6 numbers. The second prisoner needs to guess only one of 12 numbers (since the first card passed to him will eliminate one number). By passing the first card face up or face down, the first prisoner can tell the second one whether the number to be guessed is in the first half (1 - 7) or second half (7 - 13). He can encode the number using C1, C2 and C3 in a particular permutation.
@manikandan: what if the prisoners are not allowed to pass the card facing a particular direction (the jailer just hands over the card to the other prisoner without maintaining any configuration :P)
Okay, then send the first card + the difference between first and second (on a circular scale from 1 to 13) by encoding using C1, C2 and C3. Difference can never be more than 6 so it can be encoded using the other 3 cards.
mani u rock!!
Post a Comment