Hacker News new | past | comments | ask | show | jobs | submit login
Mathematics and Magic: The de Bruijn Card Trick (2015) (utexas.edu)
99 points by neamar on July 1, 2022 | hide | past | favorite | 14 comments



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.

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.

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.


Diaconis is a real character. He gave a guest lecture to my statistics class at university ... um, several decades ago. His then-current research was around the effects of unfair dice. He was going to get his grad students to roll unfair dice thousands of times and see what effects loading and shaving would have on the outcomes.

To get some unfair dice, Diaconis went to a loaded dice shop somewhere in Los Angeles to see about ordering a set of custom dice. (This was before you could order unfair dice over the internet.) Since an unfair die is intended to have one face come up more frequently than the others, he wanted each die to have a pip only on that side, with the rest blank. This would make it easier to record the results.

The proprietor of the shop looked and him strangely and said, "What kind of game are you running, buddy?"

Diaconis said, "Oh I'm not running a game. See, I'm a university professor, and I'm doing some research into the effects of unfair dice."

Proprietor: "Yeah. Sure."


If anyone else wants to know what a "perfect shuffle" is, apparently it's this: <https://en.wikipedia.org/wiki/Faro_shuffle>


Last time this came up in HN, this YouTube video of a guy performing eight consequtive Faro shuffles came up (8 perfect shuffles restores the deck):

https://youtu.be/rEoYwyHddLc


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.

[1]: <https://www.researchgate.net/publication/2809440_Using_de_Br...>

[2]: <https://www.chessprogramming.org/index.php?title=De_Bruijn_S...>


They can also be used to unlock Fords: https://hackaday.com/2018/06/18/opening-a-ford-with-a-robot-...

Because the computer just checks if the "last n digits are correct" so you don't need to restart each time. Garage door openers are susceptible to it, also.


>don't let the audience cut the deck

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...

yeah I'm still bitter.


From the blog, there is a comment from a magician with a BA in Mathematics that I quote here:

"I am a magician with a BA in Math. While the math is great where is the trick? - Perhaps you could explain about the choosing of the cards and what the mystery in the way you reveal the chosen cards, because the average spectator is not going to be awed by a “memorized stacked deck routine” no matter whether you actually memorize your stack of 32 cards, or whether you are using binary to calculate the next card from the previous. Please help me understand where the drama is as a magic trick. The truth is that as you have so far discussed it, this trick will fall flat on its face - please explain how pigrnerform it so that it is not boring

-Ronald Levy"

The reply if you are interested is that you need to be able to develop your story to somewhat condition your audience. I guess the lesson is, that all this is more interesting for Mathematicians and less to Magicians :-)


I can't find your quote in the article. Instead I find

> pass round the cards allowing the audience to cut the deck, thus not altering the cyclic order.

which makes sense. Cutting is fine, shuffling is not.


That sentence is vague. The author means that first each person cuts and then, with no further cutting, each person takes a card. If an extra cut occurs between the takings of cards, the truck fails.


I think this comes from, if you get natural respect from people or not.


Stage magicians learn ways to recover from trick errors, either by switching to another trick, replacing the deck, or having someone pull the fire alarm.


Don't tell them what you're going to do. If Joe Wise-Arse ruins it, proceed with a different trick, they won't know.

There is a 1940 booklet called "Outs" Precautions and Challenges by Charles H. Hopkins, that is devoted to precisely this problem. As I recall it is just as suitable for close-up as stage magic. It is a playing cards only book, but the principles remain valid for all magic.

There was a film industry guy, forget his name, who insisted that if someone wants to see you do some tricks (informally) you must first make them prove that it matters. Have the host set up a room or an area specifically for you to do you magic. Then require anyone who wants to see your impromptu act come to you. It's about setting a tone.

Just being very experienced and performing flawlessly sends a message as well.

Others like Slydini, simply did not perform close-up magic unless conditions were perfect, and it was very obvious that the magic was wanted. He had a presence, and a lifetime of reading audiences. When he performed, he was in charge, no one doubted it. However, Slydini, like Daryl, had tricks tailored for perfect conditions, and tricks tailored for the worst of conditions.

Some like John Carney, student of Dai Vernon for many years, are just so darn natural, that you don't realize they're doing magic until your jaw hits the table. So with John, there's simply not much chance of interrupting, because it just seems like your having a little chat. He is the master of doing things on the off beat. He often seems genuinely surprised that something magical happened. Of course his knowledge of outs is extensive.

The late lamented Daryl was not afraid to show a little bit of anger if someone kept interrupting. Nothing rude, but the offender got the message. Not everyone can do this. Daryl was amazing in his planning. When he wrote up a trick, he described exactly what conditions it was suitable for: seated, 3/4 surrounded; seated 180-degs surrounded; standing, audience in front; standing surrounded, etc. Methods differed for the same trick depending on conditions. Not every trick could be performed under every circumstance, and he noted this when describing them. He used some pretty advanced techniques known to some close-up workers to control the angles in less than favorable circumstances.

Ricky Jay, would get extremely angry if you interrupted his trick, or demanded he shuffle the cards or such. He'd lecture you with the ruined deck sitting in plain view, and remind you that you had agreed not to mess with his performance. After a minute of anger (acting?) and hectoring, he'd give in, take the deck you'd apparently ruined by shuffling, and proceed to astound you with its successful conclusion. But then, Ricky Jay was a student of magic, from ancient to the modern, that has had very few peers in that respect... perhaps Vernon, Mulholland, Marlo, Diaconis, and a few others.

Bottom line, without polish, brashness, and flawless execution, most of us will get our tricks ruined by our audience now and then. Just go the confidence store and buy a couple of large bags of the stuff. Real magic is hard work, study, and confidence. Can't help you with the last one. I feel your pain. Voice of experience.


> They repeatedly cut the deck and then take a card each.

I don't see how this works, unless the audience is picking five consecutive cards from the deck.

If you are picking 5 random cards, their colors can't encode what they are holding.

The opening sentence is totally misleading and ruins the whole explanation.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: