There are two magicians, A and B.
magic/card/guess.1.of.5 Added material
Problem
There are two magicians, A and B. B leaves the room. The spectator shuffles a pack and gives five cards to A. A lays 4 of 5 cards on the table in a row, face up, and gives fifth card to spectator. B returns to the room, looks at the 4 cards and names the fifth card.
Show solution
The 5 cards given to the first player must contain two cards of the same suit. Of these, one must be six or less greater than the other, wrapping around from K to A to 2. For example, suppose that there are two spades, the 5 and the J. The spades which are six or less greater than the J are the Q, K, A, 2, 3 and 4, and the 5 is not among these; but the spades which are six or less greater than the 5 are the 6, 7, 8, 9, 10 and J, and the J is among these. Thus of the two spades, the J is the one which is six or less greater than the 5. The first player then keeps the card which is six or less greater than the other (in the example, the J of spades) and shows the other (in the example, the 5 of spades) as the first (leftmost) of the 4 exposed cards. The remaining cards are considered ordered by rank, with A highest and 2 lowest, and among cards of equal rank in the order SHDC, with spades(S) highest and clubs(C) lowest. The first player shows the remaining three cards in one of six permutations according to this ordering, corresponding to the numbers 1 to 6, whichever of these is the difference between the hidden card and the one already shown. This means, if the three cards are called L (for low), M (for middle) and H (for high) according to the ordering, then they should be placed in one of the following orders: 1 LMH 2 MLH 3 LHM 4 HLM 5 MHL 6 HML thus in the example, he would place them in the order HML, since the J of spades is 6 greater than the 5. When the second player returns to the room, he knows that the hidden card is of the same suit as the leftmost card, and he adds to the rank of this card the number 1 to 6 corresponding to the permutation of the remaining three cards, thus identifying the hidden card uniquely. In the example, the second player sees 5S H M L and since HML corresponds to 6, he adds 6 to the 5 of spades to get the J of spades. Of course, the first player may have more than one choice, since there might be three cards of the same suit, or two cards each of two different suits, but he simply chooses one pair of cards of the same suit, and the fact that there are other choices is irrelevant. See also URLs: http://www.anamorph.com/docs/ct/cards.html http://www.frontiernet.net/~jmb184/interests/puzzles/4_of_5_trick.html
Additional material
[ Editor: a web page "Four of Five" (http://www.jfitz.com/cards/),
January 1998, that performs the trick in JavaScript: the user enters
the four cards in the order given, and the page names the fifth. The
page text follows, then its script in full. ]
Four of Five
Here is the situation. You pick five cards at random from the deck.
You give these cards to John, who selects one card he returns to you
face down. The other four cards, he gives back to you, one at a time.
You enter these cards into the form below. When finished, you press
"Do it". Now turn the face down card over. That should be the fifth
card.
[form: four cards, each chosen as a rank (Ace ... King) and a suit
(Clubs, Hearts, Diamonds, Spades); buttons "Do It" and "Clear"]
And the fifth card is: [result]
Trick first implemented by Robert Orenstein
(http://www.anamorph.com/docs/ct/cards.html).
Crafted lovingly from Javascript by John Bailey, January, 1998.
Card images by John Fitzgibbon.
Don't send money, send respectful admiration.
version 1.01 21:17 January 22, 1997
[ Editor: in the form, the list "y" gives the ranks the values 1 to 13,
the list "y1" gives the suits the values Clubs=0, Hearts=13,
Diamonds=23, Spades=39, and the list "w1" gives them 0 to 3. The
header comment of the page (its time-stamp and distribution notice),
then the script: ]
-----BEGIN PGP SIGNED MESSAGE-----
########################################################
#
# The text of this message was stamped by
# stamper.itconsult.co.uk with reference 0014108
# at 20:06 (GMT +0000) on Sunday 01 February 1998
#
# For information about the Stamper service see
# http://www.itconsult.co.uk/stamper.htm
#
########################################################
JavaScript Four-of-Five-Card trick - Scripted by John Bailey -
jmb184@frontiernet.net
January 22, 1998, All Rights Reserved
May be freely redistributed, if no charge is made for the program.
The source code may be used and modified for personal and educational
use,
but incorporating all or a substantial portion of the code into a
commercial
product is prohibited.
The author of this program accepts no responsibility for damages
resulting
from the use of this product and makes no warranty or representation,
either
express or implied, including but not limited to, any implied warranty
of
merchantability or fitness for a particular purpose. This software is
provided "AS IS", and you, its user, assume all risks when using it.
function ClearForm(form)
{ form.x.value = "";
form.x1.value = "" ;
form.y.value = "";
form.y1.value = "";
form.z.value = "";
form.z1.value = "";
form.w.value = "";
form.w1.value = "";
form.result.value = "";
update(this.image,form) ;
document.images[4].src = "b1fv.gif" ;
}
function update(image,form)
{ document.images[0].src =
form.x1.options[form.x1.selectedIndex].value +
form.x.options[form.x.selectedIndex].value + ".gif"
document.images[1].src =
form.x1.options[form.y1.selectedIndex].value +
form.x.options[form.y.selectedIndex].value + ".gif"
document.images[2].src =
form.x1.options[form.z1.selectedIndex].value +
form.x.options[form.z.selectedIndex].value + ".gif"
document.images[3].src =
form.x1.options[form.w1.selectedIndex].value +
form.x.options[form.w.selectedIndex].value + ".gif"
}
function computeform(form)
{ var r, x, x1, y, y1, z, z1, w, w1, m, r, s, u, i, j ;
x = parseInt(form.y.options[form.x.selectedIndex].value) ;
x1 = parseInt(form.y1.options[form.x1.selectedIndex].value) ;
y = parseInt(form.y.options[form.y.selectedIndex].value) ;
y1 = parseInt(form.y1.options[form.y1.selectedIndex].value) ;
z = parseInt(form.y.options[form.z.selectedIndex].value) ;
z1 = parseInt(form.y1.options[form.z1.selectedIndex].value) ;
w = parseInt(form.y.options[form.w.selectedIndex].value) ;
w1 = parseInt(form.w1.options[form.w1.selectedIndex].value) ;
x = x + x1 ;
y = y + y1 ;
z = z + z1 ;
i = 0 ;
r = x ;
if (y < r) {
r = y ;
i = 1 ; }
if (z < r) {
r = z ;
i = 2 ; }
if (i == 1) {
y = z ; }
if (i == 0) {
x = y ;
y = z ; }
u = 1 ;
if (x < y) u = 0 ;
r = (w + 2*i + u) % 13 ;
document.images[4].src = form.x1.options[w1].value +
form.x.options[r].value + ".gif" ;
form.result.value = form.y.options[r].text + " of " +
form.y1.options[w1].text;
return;
}
/*
-----BEGIN PGP SIGNATURE-----
Version: 2.6.3i
Charset: noconv
Comment: Stamper Reference Id: 0014108
iQEVAgUBNNTV3oGVnbVwth+BAQGoCQf7BZ1ct61kZHXykxmKHUlh9LT4BtHpPAcs
Nb1atZyFsuVxGEJoqqRrJsjYPXQJTL0uB02oiPxFIUmJKzk946pYyX/TR40Gqnbo
KpsdKWK8s7X/LcHbmFV9MC1vS6U0MbPl0gp9iuOWK6aEUEKQSE04Z4aWim/GjyFJ
d9gmL6fCrkD+t/EgoFCqBGN9K7gJciCIwZ044Q2cadEY4NvYrEXqqMcHWQDGonIb
e55WnJLOM7V5gQd/4Xnkl67ZGp9kq6Jx2G5kKtuVpQ+H9kuQXbFogOZdD+/NCerQ
Wi47NdAaZc9RVBfda+NLhpnPXYxZhpo4XG4JaNj1otY1DWaZ8FZuSw==
=v+Rj
-----END PGP SIGNATURE-----
*/
-- John Bailey <jmb184@frontiernet.net>