Match hands with 4-Card lists

Mathematics for Computer Science
MIT 6.042J/18.062J
Tricks with Counting
& Matching
Jay R Meyer, April 14, 2009
lec 10T.1
The Magic Trick
Students choose 5 cards
Eli reveals 4 of them
th
Jay announces 5 card!
Jay R Meyer, April 14, 2009
lec 10T.2
The Magic Trick
Let’s do it!
Jay R Meyer, April 14, 2009
lec 10T.3
Eli’s Choices
Decide the order of the 4 cards:
4! = 24 orderings
-- but 48 cards remain
Decide which 4 cards to list
Jay R Meyer, April 14, 2009
lec 10T.4
Map hands to 4-Card lists
5-card hands
(no order)
?
4-card lists
(ordered)
list must come
from hand
Which one to pick?
Jay R Meyer, April 14, 2009
lec 10T.5
Map hands to 4-Card lists
5-card hands
(no order)
4-card lists
(ordered)
?
How can we ensure
consistency?
Jay R Meyer, April 14, 2009
lec 10T.6
Map hands to 4-Card lists
5-card hands
(no order)
4-card lists
(ordered)
Every hand must have
an identifying list!
Jay R Meyer, April 14, 2009
lec 10T.7
perfect matching of the hands
5-card hands
(no order)
4-card lists
(ordered)
Every hand must have
an identifying list!
Jay R Meyer, April 14, 2009
lec 10T.8
Match hands with 4-Card lists
5 
deg =   × 4! = 120
4
deg = 52-4 = 48
Jay R Meyer, April 14, 2009
lec 10T.9
Match hands with 4-Card lists
So graph is
degree-constrained
and hence has a matching
that Eli & Jay can use
(works for a bigger deck too)
Jay R Meyer, April 14, 2009
lec 10T.10
A Memorable Matching?
 52 
  = 2,598,960 hands to
5 
match
How will Eli & Jay
learn any matching this big?
Jay R Meyer, April 14, 2009
lec 10T.11
Magic Trick Revealed (I)
Among 5 cards chosen:
at least 2 have the same suit
(Pigeonhole Principle)
Eli lists one of them 1st
Aha! The first card has the
same suit as the hidden card!
Jay R Meyer, April 14, 2009
lec 10T.12
Magic Trick Revealed (II)
How does Jay figure out the
rank of the hidden card?
Aha! Look at the order
of the other 3 cards!
Jay R Meyer, April 14, 2009
lec 10T.13
Magic Trick Revealed (II)
Fix ordering of the deck
A♣ < A♦ < A♥ < A♠ <
2♣ < 2♦ < 2♥ < 2♠ <
K♣ < K♦ < K♥ < K♠
Jay R Meyer, April 14, 2009
lec 10T.14
Magic Trick Revealed (II)
Possible orders for the
remaining 3 cards:
{ SML, SLM, MSL, MLS, LSM, LMS }
Jay R Meyer, April 14, 2009
lec 10T.15
Magic Trick Revealed (II)
Wait! Only have 6 lists of the
remaining 3 cards, but
12 possible hidden cards
of the known suit!
Of two cards with the same suit,
choosing which to reveal can give 1
more bit of information!
Aha!
Jay R Meyer, April 14, 2009
lec 10T.16
Clockwise Distance
The smaller clockwise distance
between 2 card ranks is at most 6:
K
Q
J
Hide card
with smaller 9
offset.
A
2
7
10
8
3
6
7
Reveal the
other card
6
Jay R Meyer, April 14, 2009
4
5
lec 10T.17
Magic Trick Revealed (Finally)
• The first card determines the
hidden suit (♠ ♥ ♦ ♣) .
• Hidden rank (A … K)
= first-card rank + offset (≤ 6).
• Offset given by order of
remaining 3 cards:
SML = 1, SLM = 2, MSL = 3,
MLS = 4, LSM = 5, LMS = 6.
Jay R Meyer, April 14, 2009
lec 10T.18
Example
same suit
First:
Hidden:
Offset = 1 = SML:
Jay R Meyer, April 14, 2009
lec 10T.19
won’t work with 4-card hands
Students
can pick
 52 
  = 270,725
 4
Eli can
reveal
52!
=132,600
49!
possible 4-card possible 3-card
hands
lists
Jay R Meyer, April 14, 2009
lec 10T.20
won’t work with 4 card hands
so at least
 270,225 
=
3
 132,600 


hands map to the same list
– Jay can’t tell which!
Jay R Meyer, April 14, 2009
lec 10T.21
Team Problems
Problems
1&2
Jay R Meyer, April 14, 2009
lec 10T.22