1.

Demonstrate the De Bruijn card trick for your family. As a reminder it works as follows. We encode each card with a binary number, the first digits corresponding to the suit according to the table below, and the last three digits the given number in binary (with Ace = "001" and 8 = "000").

00club
01spade
10diamond
11heart


Thus the 3 of spades would be written 0 1 0 1 1 .

Next we have a rule to find the next card, namely we drop the leftmost digit, and add a 0 to the right if the leftmost and middle digit were the same, and a 1 if they were different. For example, starting with the 3 of spades as above the next one would be

1 0 1 1 0

because the the leftmost and middle digits were the same (both zero). This is a 6 of diamonds, so that would be the next card in the stack. Continuing in this way, we can figure out the next card "0 1 1 0 0" (a 4 of spades) all the way 'till we get back to where we stared. Now the deck is sorted so that if you know the colors of the first five cards, you know what the first card is, and can use the sequence to figure out what all the rest are.

As a side note, someone asked why the 5th and 3rd digits. This has to do with the fact that x5 + x3 + 1 is a primitive polynomial and what you are doing is essentially a linear feedback shift register.





2.

We only used the cards Ace up to 8, except for the 8 of clubs. What would happen if you used the 8 of clubs? Can you do it with all 52 cards in the deck if you only are told 5 colors? What does the number of cards you use (31) have to do with the binary numbers with exactly 5 digits?





3.

While playing this game, your friend notices four cards, which happen to be 3 3 8 8, can be arranged to make 24. This is your favorite game, but after staring at it a while you think it can't be done. It turns out it can be done, but you need to use division. How?