# Card Trick Explained with Combinatorics

Don't ask me why mind works that way, but for some reason I reacalled a card trick that a neighbor kid showed me when I was little. At the time I found it impressive that such things can even work. And today I could not really recall how the trick worked from the performer, but how it appears to the audience.

The general idea is this: You have regular playing cards and take a selection of 20 unique ones. Then they get paired up and shown to the audience alone. Each audience member picks one such pair and remembers them without telling the performer. Then the performer blindly stacks all those pairs and puts down the cards in a seemingly weird pattern with four rows and five columns. Each audience member indicates the rows (or row) that their pair is located at. The performer then tells them which cards they have picked.

As the performer does not necessarily have seen the pairs beforehand, he does not know which card belongs to which other card. Knowing only the row or rows seems a bit too little information. But then the solution just hit me while I continued to look at the trees outside: There are 10 pairs. And there are 4 possibilities to chose a single row and 6 possibilities to choose two different rows. So one only needs to make sure that there is only one pair which has this particular combination.

So let us go through it from the performer's perspective. The actual printing on the cards does not matter for us, we just need to know that the cards are paired up. I indicate this with the same fill color.

Now the audience member basically has chosen a particular color. Next we arrange the cards into a pattern which just happens to fulfil the requirements.

In the first two columns you have the pairs that reside on the same row. Then the yellow-green, green and green-blue form a staircase with the options of a pair being in adjacent rows. The light-blue and dark-blue are in rows with a separation of one row, and the purple ones with two. We can easily see that there is only one pair which matches the row information given by an audience member.

But putting these cards down just in this pattern might be a bit obvious for the audience. So we can just permute each row and the order that the cards are put down to make it look less obvious. One classic way is the following.

You would put them down following the rainbow or in some other pattern. All what matters is that paired cards end up on same-colored locations. It is not as neatly constructed as the one that I have shown above, so it makes the card trick appear even more magical.

And after reconstructing the trick up until here, I even recalled first word of the mnemonic and was able to find the whole phrase. It is just a meaningless German sentence where each letter occurs exactly twice. And you can match up the letters to the colors above and see that it is the same pattern.

```
BOSCO
BIATI
KENNT
ALLES
```

Now one could try to construct similar ones with a different number of cards. Basically the number of pairs $p$ that one can fit into $r$ rows is $$ p = r + \binom{r}{2} \,. $$ The number of columns $c$ then is $$ c = \frac{2 p}{r} \,. $$

We can try to see which number of rows is possible. Of course I am lazy and just compute that in R:

```
df <- data.frame(rows = 1:10)
df$pairs <- df$rows + choose(df$rows, 2)
df$columns <- 2 * df$pairs / df$rows
```

And apparently the numbers work cleanly for every number of rows that you could think of.

Rows $r$ | Pairs $p$ | Columns $c$ |
---|---|---|

1 | 1 | 2 |

2 | 3 | 3 |

3 | 6 | 4 |

4 | 10 | 5 |

5 | 15 | 6 |

6 | 21 | 7 |

7 | 28 | 8 |

8 | 36 | 9 |

9 | 45 | 10 |

10 | 55 | 11 |

Well, but can we construct the pattern? Yes, the construction works just as it did before. We take 15 pairs, the first two columns are for pairs on the same row and then we have this staircase construction.

One would just have to permute them a bit to make it look more magical and less mathematically constructed. If one sees this trick again with 10 pairs, one should just offer to do it with 15 or 21 pairs and see whether the performer is impressed by that.