How Many Ways Can You Order a Deck of Cards?
Tags: Math
Do you fidget?
When you are in a state of deep thought or boredom in a meeting, a class lecture, or by yourself, are you someone who clicks their pen? Or perhaps you spin it around your thumb? Do you tap your foot? Did you ever have one of those little fidget cube toys with all the little buttons to press?
I certainly fidget. Here’s what I do: I shuffle cards. A lot. And I have for a long time. At the ripe age of five years old I became a magician, and as soon as I learned how to shuffle cards it became my goto way to occupy my hands.
This is a habit that I’ve carried with me into adulthood despite not being a magician anymore. Whether I’m on the phone, or watching a movie, or just in a deep state of thought, it is not uncommon at all for me to have a deck of cards in my hands. It’s difficult to estimate, but the number of times I’ve shuffled cards in my life is probably in the hundreds of thousands.
Here's a question. What are the odds that I've shuffled a deck of cards into the same order as any deck that I have ever previously shuffled? That is, what is the probability that throughout all of the hundreds of thousands of permutations that I created over a nearly twodecade span, that I ever produced an ordering of cards that was identical to any other order that I have ever produced?
Another question. What are the odds that two shuffled decks have ever matched– period. From all of the permutations created by every magician that has ever lived, combined with every round of poker that has ever been played at every casino across the globe, combined with every round of every card came from euchre to solitaire that have ever been played– what are the odds that two decks of cards have ever matched at any point in time? What if we include online poker and card games too– any computer that has ever produced random orders of cards for any reason, what then? There are only 52 cards in a deck, how many ways could there possibly be to arrange them?
Let’s test your intuitions on this. Guess which option the number of possible decks of cards is closest to: the number of grains of sand on Earth, the number of atoms on Earth (sand and all), or the number of atoms in the sun (which is ~333,000 times the mass of Earth).
If you guessed the number of the atoms in the sun, you would be correct. You would also be underselling it. The number of possible decks of cards absolutely dwarfs the number of atoms in the sun.
To answer the two questions above, the probability that any two decks of cards have ever matched is effectively exactly 0%. I’ll maintain a grain of epistemic humility here and concede that since we haven’t checked all the decks across all of time we can’t technically be certain, but it would be a statistical miracle if two decks have ever matched, as I will soon illustrate. If you pause reading this and go shuffle a deck of cards right now it is essentially guaranteed that you will produce a brand new deck of cards never before seen by humanity. And if you shuffle the cards again without recording the previous ordering of cards, that deck will almost certainly never be seen again by man or machine– ever.
To understand why we must first familiarize ourselves with permutations. A permutation is an ordering of items where the order matters. For example, your highschool locker “combination” was actually a permutation, because you had to input certain numbers in a certain order (in a true “combination” the order wouldn’t matter). Your debit card PIN code is another example of a permutation.
In both of those examples the items have the ability to repeat. Your PIN code could be 7777. This is not always the case. Imagine I have 4 coins: a penny, a nickel, a dime, and a quarter. I want to list all of the ways they could be arranged from left to right. For spot #1 I have 4 options, so I can select any coin. Let’s say the dime. Once the dime is in spot #1 I can’t select it again for any other spots, it can’t repeat, so that means I only have 3 coins left for spot #2. After the quarter goes into spot #2 I only have 2 possible coins left for spot #3. Once the penny goes into spot #3, only the nickel can go into spot #4.
If I want to know how many possible permutations of 4 coins there are, I need to multiply together the number of options I have for each selection:
4 x 3 x 2 x 1 = 24
There are 24 ways I can arrange 4 coins. This process of multiplying all of the positive integers together between 1 and the total number of objects is the same process for finding the number of possible permutations for all permutations that don’t have repetition. This is referred to as a factorial and is denoted with an exclamation point, so the above equation could also be represented like this:
4! = 24
The tricky part about factorials is that they get absurd very quickly. What begins with a simple exercise in multiplication ends up leading us to mindbendingly large numbers. To illustrate my point, let’s go back to playing cards. What we want to do is find 52! (the factorial of 52), which is to say:
52 x 51 x 50 x 49 x 48 … etc.
I’ll save you the trouble. Here’s the answer:
80,658,175,170,943,878,571,660,636,856,403,766,975,289,505,440,883,277,824,000,000,000,000
This number bounces off of our heads like it’s a beach ball, it means nothing to us, it is totally incomprehensible. This number has 68 digits. To at least attempt grappling with it we will write it and all similarly sized numbers in scientific notation, which for the beast aboves looks like this:
8.0658 × 10^67
I have the recipe for how we can explore all of these permutations. You can follow along at home, you will need only two things:

Decks of cards (many).

Godlike powers over the universe.
Step 1)
Shuffle a deck of cards once per second. Do this for a year. This will amount to about 31.54 million shuffles.
This is, to put it mildly, too slow. We need more people.
Step 2)
There are about 7.8 billion people on the planet right now, and it’s estimated that about 100 billion people have ever lived. Put your necromancer hat on and resurrect the entire history of Earth’s human population– every bloodline from every time period until we have 100 billion people walking the Earth at the same time. Then give each of them a deck of cards and instruct them each to shuffle once per second.
100 billion people * 31.54 million shuffles per person per year = 3.154 * 10^18 shuffles per year (three quintillion one hundred fiftyfour quadrillion).
For any other task this would be quite the feat, but given what our goal is, this produces such a pitiful amount of progress that it’s indistinguishable from doing nothing at all. You will have to think larger.
Step 3)
The Milky Way conservatively contains 100 billion planets. Erase all of them and replace them with clones of our new shufflingobsessed Earth:
3.154x 10^18 shuffles per planet per year * 100 billion planets = 3.154 × 10^29 shuffles per year (three hundred fifteen octillion four hundred septillion).
We’re going in the right direction, but we are still lightyears away from our goal. We need to use all of the space that we have at our disposal.
Step 4)
There are an estimated 2 trillion galaxies in the observable universe. Disintegrate them all back into space dust and place a duplicate of our new Milky Way where each of them were:
3.154 x 10^29 shuffles per year per galaxy * 2 trillion galaxies = 3.154 x 10^41 shuffles per year.
So far this has all just been over one year. We need more time than that. How about we use all of the time there has ever been?
Step 5)
Take this entire supercluster of galaxies and time travel back to the dawn of the universe 13.7 billion years ago, and then let the clock run from then until now:
3.154 x 10^41 shuffles per year * 13.7 billion years = 4.32098 × 10^51 total shuffles.
This is still nowhere near our goal. Perhaps one universe isn’t enough.
Step 6)
Create a multiverse where you set off 100 trillion big bangs, each spawning a universe just like the one we’ve already created:
4.32098 x 10^51 shuffles per universe x 100 trillion universes = 4.32098 x 10^65 total shuffles.
You are still not there. Not even close. We are ridiculously far off. Don’t let the 65 in the total shuffles number fool you into thinking that we’re close to the 68digit number that is 52!. In case you are not used to working with numbers in scientific notation, let me point out that the number that we are off by is also a 68digit number!
We created a multiverse with 100 trillion universes, each containing 2 trillion galaxies, that each contain 100 billion planets, where each planet hosts 100 billion people, and where each person across every planet in every galaxy across the entire multiverse is shuffling a deck of cards every second, and then we left this arrangement to continue for every second for 13.7 billion years, and we’ve barely made a dent. Out of the 8.0658 x 10^67 permutations we started with we still have about 8.0226 x 10^67 permutations to go. And a generous amount of that progress is from a rounding error from the way I’ve just written those numbers.
To go through all of the permutations this experiment would have to run not for 13.7 billion years, but for over 2.5 trillion years. A mere 510 billion years into this experiment you will have to begin refueling the stars that all of the planets orbit across the multiverse, lest they explode and destroy your work.
It’s strange to think that a numberspace this large can be contained within a household deck of cards– a nonelectronic object that you can fit in your pocket. This kind of impossibletobrutefroce numberspace is the foundation of cryptography, which itself is the foundation of both cybersecurity and blockchain technology. Imagine how many possibilities there are for a security key that is not 52 cards long but hundreds of characters long, from a selection of over one hundred possible characters, and where repeating is allowed. There are obviously endless things to say about both topics, but I will leave this here for now.
© Joseph Bowen