# Brent Morris: Magician and Computer Scientist

The magicians' art of shuffling in special ways to make tricks, like the 21-card trick, work can also help us build computers. Magicians want to move cards around efficiently; computers want to move data around in their memory efficiently.

## Perfecting the perfect shuffle

In a perfect shuffle, the magician cuts the cards exactly in half and perfectly interlaces them, alternating one card from each half. It takes years of practice to do but does look impressive. There are 2 kinds of perfect shuffles: With an out-shuffle the top card of the deck stays on top. With an in-shuffle the top card moves to the second position of the deck. Magicians know that 8 perfect out-shuffles restore the deck to its original order! It looks like the deck has been really mixed up, but it hasn't.

8 perfect out-shuffles restore the deck to its original order!

Computer scientist Brent Morris was fascinated by magic. In particular he became interested in the "perfect shuffle" in high school and has pursued its mathematics for more than 30 years with some amazing results. He earned his Doctorate in Maths from Duke University, and a Master's in computer science from Johns Hopkins University in the United States. He is believed to have the only doctorate in the world in card shuffling. He also holds two US patents on computers designed with shuffles, and has written a book on the subject called 'Magic Tricks, Card Shuffling, and Dynamic Computer Memories'. Why the interest in perfect shuffles?

## Binary shifts - as if by magic

You can use perfect shuffles to move the top card to any position in the pack, using a little bit of the maths behind computers: binary. Suppose you want the top card (let's call that position 0) to go to position 6. Write 6 in base 2 (binary), giving 110 (1x4+1x2+0x1). Now read the 0's and 1's from left to right: 1:1:0. Then, working through the 1's and 0's, you perform an out-shuffle for a 0 and an in-shuffle for a1. In our case that means:

1: an in-shuffle, first
1: another in-shuffle,
0: and finally, an out-shuffle

As if by magic (if you are capable of doing perfect shuffles) the top card will have moved to position 6. Of course it works whatever the number, not just 6. What does this have to do with the design of computers? You can use exactly the same ideas to move data efficiently around computer memory, which is what Brent Morris discovered and patented.

## Curtain call

So as you impress your friends with your 21-card trick, coming up with your own performance ideas and are basking in that applause, remember two things. Number one: a magician never reveals their secrets. Number two: computers don't work by Hogwart's magic ... only by mathematical magic.