# A magic trick of David Copperfield

David Copperfield puts $52$ cards numbered $1$ to $52$ into three top hats. One of these top hats is red, one is blue and one is yellow, and each of them receives at least one card. Then David Copperfield is blind-folded. Some guy from the audience draws two cards from two different hats, and then loudly announces the sum of the numbers on these two cards. Copperfield hears this sum, and immediately announces the colour of the top hat from which no card has been drawn.

How does this trick work? How many ways are there for David Copperfield to put the cards in the three hats so that the trick always works?

• No idea, but really good puzzle. Commented Mar 30, 2016 at 10:17
• Does David Copperfield and the audience know as to which card is in which hat? Commented Mar 30, 2016 at 10:22
• Yes Copperfield knows. Commented Mar 30, 2016 at 10:23
• The first part seems easy.If we divide the numbers with same mod 3 in one group, then sum of their mod will be the same as the mod of the group from which no card is drawn.<BR> Now,since there are 3 groups, there would be $3!=6$ ways of arranging the cards in the 3 hats.I just hope this not the intended solution, otherwise this question is just like a math exercise. Commented Mar 30, 2016 at 10:30
• @2012rcampion Oh! So, the challenge here is to find other ways or prove they do not exist. Commented Mar 30, 2016 at 10:59

Claim: If David Copperfield distributes $$n\ge3$$ cards with numbers $$1,2,\ldots,n$$ over the three top hats, then only the following two types of distributions make the trick work:

• Put $$1,2,3$$ into different hats; put every $$k\ge4$$ into the same hat as its residue modulo $$3$$.
• Put $$1$$ into the first hat; put $$2,\ldots,n-1$$ into the second hat; put $$n$$ into the third hat.

Hence the answer to the puzzle is that there are exactly twelve ways to put the $$52$$ cards into the top hats so that the trick always works.

## Proof of the claim

The proof is by induction on $$n\ge3$$. The case $$n=3$$ is trivial, as every hat must receive at least one card (note that in this case the two distribution types coincide). In the inductive step to $$n+1$$, we distinguish several cases.

(1). Assume that $$n+1$$ is alone in its hat and $$1$$ is alone in its hat. Then we have the second distribution. Done.

(2). Assume that $$n+1$$ is alone in its hat, and $$1$$ is not alone in its hat. Take the highest card $$x$$ in the hat containing $$1$$, and take the highest card $$y$$ in the third hat that neither contains $$1$$ nor $$n+1$$. Note that $$2\le x$$ and that $$2\le y\le n$$, and that $$\max\{x,y\}=n$$. Then the sum $$S=x+y$$ satisfies $$n+2\le S\le (n-1)+n=2n-1$$.

• The guy from the audience might pick $$x$$ and $$y$$ with sum $$S$$.
• On the other hand, the guy from the audience might pick card $$n+1$$ (which is sitting alone) together with the card $$z=S-(n+1)$$ from one of the other two hats. These two cards are coming from different hats, but yield the same sum $$S$$. Hence Copperfield's trick will fail in this case. Contradiction.

(3). Finally assume that $$n+1$$ is not alone in its hat. Then we may remove card $$n+1$$ from its hat, and get a smaller working situation for the trick with only $$n$$ cards. In this case, the inductive assumption exactly describes the possible distributions for cards $$1,\ldots,n$$.

(3a). If the cards $$1,\ldots,n$$ are distributed modulo $$3$$, then $$n-2$$, $$n-1$$, $$n$$ are in three different hats. Since $$(n-2)+(n+1)=(n-1)+(n)$$, we conclude that card $$n+1$$ must be in the same hat as card $$n-2$$; otherwise Copperfield would not know how to react when he hears the sum $$2n-1$$. Done.

(3b). If the cards $$1,\ldots,n$$ are not distributed modulo $$3$$, the inductive assumption yields that $$1$$ is on its own, that $$n$$ on its own, and that $$2,\ldots,n-1$$ are together. We may also assume that $$n\ge4$$ (as for $$n=3$$ we have the modulo $$3$$ distribution, which was discussed above). In this case we are in trouble.

• First, if $$1$$ and $$n+1$$ are in different hats, then $$(1)+(n+1)=(2)+(n)$$ make the trick fail if Copperfield hears the sum $$n+2$$.
• Secondly, if $$1$$ and $$n+1$$ are in the same hat, then $$(2)+(n+1)=(3)+(n)$$ make the trick fail if Copperfield hears the sum $$n+3$$.

• Could you explain the contradiction part.I did not get it. Commented Mar 30, 2016 at 14:01
• @Roby5: Suppose you can take $a$ and $b$ from hats 1 and 2, and you can take $c$ and $d$ from hats 2 and 3. If $a+b=c+d=:S$, then the trick does not work: If Copperfield hears the sum $S$, he does not know whether the unused hat is 3 or whether the unused hat is 1. Commented Mar 30, 2016 at 14:03

One way to do this

Place 1 in the red hat, 52 in the blue one and rest in the yellow

If sum is $53$, it is only possible that one card is drawn from the red hat and one from the blue

If sum $> 53$, the blue hat card and a yellow hat card has been drawn

Else, a card from the red hat and one from the yellow hat has been drawn

• This works, but the audience might not be too impressed as its too obvious. :P Commented Mar 30, 2016 at 14:05
• Doesn't this mean that 51 AND 2, 50 AND 3, etc. are on the yellow? Their sum is 53. I may got it wrong, but I don't think this is correct.
– zozo
Commented Mar 31, 2016 at 11:19
• @zozo cards 51, 2, 50, and 3 are all in the same hat. The puzzle requires that you draw two cards from two different hats Commented Mar 31, 2016 at 12:14
• @Timmy It is stated: If sum is 53, it is only possible that one card is drawn from the red hat and one from the blue. Considering that 50 and 3 are in yellow, that is incorrect.
– zozo
Commented Apr 1, 2016 at 5:56
• @zozo They meant 53 = 52(blue) + 1(red). No other combination can be drawn from two different hats Commented Apr 1, 2016 at 9:51

He can put all cards 0 mod 3 in the red hat, all 1 mod 3 in the blue hat and all 2 mod 3 in the yellow hat.

If the sum is 0 mod 3, it can only be obtained from 1+2 mod 3, so the unused hat is red. The same goes for 1 mod 3, it can be obtained from 0+1 mod 3, so the hat is yellow. For 2 mod 3 we have 0+2 mod 3, so the hat is blue.

• Well, seems ,like @Roby5 said this in one comment before me Commented Mar 30, 2016 at 10:41

There are more than one way to do this. For example;

• the number of hats mod which requires putting all the same numbers in "the number of hats" mod. For this one it is mod 3. (explained by @BianB BB's solution)
• Putting the smallest number in one hat, largest number in one hat, and the rest is the last hat. 1 is the smallest, 52 is the biggest. You cannot have more than 52 if 1 and any number less than 52 comes. or you cannot have less than 54 for 52 and any number bigger than 1.
• @KateGregory you cannot have 50+3 since 50 and 3 are in the same hat. 1 and 52 are in the different hats.
– Oray
Commented Mar 30, 2016 at 12:30