Note: I found this puzzle on quora. I don't have a solution for it. I couldn't find it referenced using google search.
This time the jailor gives two of his favourite prisoners a chance to escape.
He tells them that, on the following day he would take one of the prisoners to a closed cell which has only a small opening in a wall, large enough for a hand to fit in. The second prisoner would be standing on the other side of the opening outside the cell. He would then give, 5 cards randomly (from a deck of 52 cards) to the prisoner in the cell and then, the prisoner after having a look at all the 5 cards, should return one card back to the jailor and pass on the remaining 4 cards one by one to the second prisoner outside through the hole.
The jailor then comes out to the second prisoner and asks him to name the card which has been returned by the first prisoner. If he names it right, both go scot free!
Note: The prisoner can take some time before passing the cards, but once he starts he has to pass them quickly in succession. Also, all cards should be passed face-up only!
Now both the prisonsers who share the same cell have one full day to devise a strategy so that no matter who is picked up by the jailor and whichever 5 cards he chooses to give to that prisoner, the second prisoner should name the 5th card correctly after looking at the 4 cards passed on to him. How do they do it?