I watched Persi give a talk where he demonstrated this trick, as part of a lecture on ways to use finite field theory to find de Bruijn sequences.<p>I hadn't seen Persi in a while; we'd written the "seven shuffles" paper together. Catching up, I asked him privately afterwards why he didn't use a sequence where two bits encoded the suit, then three bits encoded the card. He grinned wildly, then pulled out a spare deck to establish this was indeed what he had actually done. The spare deck was wrong. He joked how he dodged a bullet not using that deck.<p>That evening I burst out laughing in a solemn moment of an earnest modern dance performance. This was embarrassing, to say the least. I had recalled that Persi had shuffled the deck once as part of his demonstration of the trick. He's a legendary magician one rarely sees performing. Perfect shuffles were easy for him.
De Bruijn sequences can also be used to quickly find the index of 1 in a word, when your CPU doesn't provide a dedicated instruction like lzcnt[1] (or when you're in a language competition which doesn't allow writing inline assembly). The paper talks only about 32-bit words, but you may find a 64-bits long de Bruijn sequence (B(2, 6)) on the Chessprogramming Wiki[2], which allows you to trivially generalise the algorithm for 64-bit words.<p>[1]: <<a href="https://www.researchgate.net/publication/2809440_Using_de_Bruijn_Sequences_to_Index_a_1_in_a_Computer_Word" rel="nofollow">https://www.researchgate.net/publication/2809440_Using_de_Br...</a>><p>[2]: <<a href="https://www.chessprogramming.org/index.php?title=De_Bruijn_Sequence&mobileaction=toggle_view_mobile" rel="nofollow">https://www.chessprogramming.org/index.php?title=De_Bruijn_S...</a>>
>don't let the audience cut the deck<p>this doesn't play so well when you get that one person who smirks at you and shuffles the (reduced) deck and ruins it all for you, then crows about how you're a fraud...<p>yeah I'm still bitter.
> They repeatedly cut the deck and then take a card each.<p>I don't see how this works, unless the audience is picking five <i>consecutive</i> cards from the deck.<p>If you are picking 5 random cards, their colors can't encode what they are holding.<p>The opening sentence is totally misleading and ruins the whole explanation.