TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Mathematics and Magic: The de Bruijn Card Trick (2015)

99 pointsby neamaralmost 3 years ago

4 comments

Syzygiesalmost 3 years ago
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&#x27;t seen Persi in a while; we&#x27;d written the &quot;seven shuffles&quot; paper together. Catching up, I asked him privately afterwards why he didn&#x27;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&#x27;s a legendary magician one rarely sees performing. Perfect shuffles were easy for him.
评论 #31949178 未加载
评论 #31944544 未加载
yakubinalmost 3 years ago
De Bruijn sequences can also be used to quickly find the index of 1 in a word, when your CPU doesn&#x27;t provide a dedicated instruction like lzcnt[1] (or when you&#x27;re in a language competition which doesn&#x27;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]: &lt;<a href="https:&#x2F;&#x2F;www.researchgate.net&#x2F;publication&#x2F;2809440_Using_de_Bruijn_Sequences_to_Index_a_1_in_a_Computer_Word" rel="nofollow">https:&#x2F;&#x2F;www.researchgate.net&#x2F;publication&#x2F;2809440_Using_de_Br...</a>&gt;<p>[2]: &lt;<a href="https:&#x2F;&#x2F;www.chessprogramming.org&#x2F;index.php?title=De_Bruijn_Sequence&amp;mobileaction=toggle_view_mobile" rel="nofollow">https:&#x2F;&#x2F;www.chessprogramming.org&#x2F;index.php?title=De_Bruijn_S...</a>&gt;
评论 #31947661 未加载
jimmygrapesalmost 3 years ago
&gt;don&#x27;t let the audience cut the deck<p>this doesn&#x27;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&#x27;re a fraud...<p>yeah I&#x27;m still bitter.
评论 #31944898 未加载
评论 #31944140 未加载
评论 #31944144 未加载
评论 #31959467 未加载
alisonkiskalmost 3 years ago
&gt; They repeatedly cut the deck and then take a card each.<p>I don&#x27;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&#x27;t encode what they are holding.<p>The opening sentence is totally misleading and ruins the whole explanation.