# Every time you shuffle a deck of cards, the sequence has never existed before

**URL:** <https://boards.straightdope.com/t/every-time-you-shuffle-a-deck-of-cards-the-sequence-has-never-existed-before/937719>\
**Category:** Miscellaneous and Personal Stuff I Must Share\
**Created:** [March 11, 2021, 4:31pm UTC](https://boards.straightdope.com/t/every-time-you-shuffle-a-deck-of-cards-the-sequence-has-never-existed-before/937719 "2021-03-11T16:31:31Z")\
**Posts on this page:** 20\
**Page:** 3

<div class="post-metadata">

**Author:** ![running\_coach](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/running_coach/32/15836_2.png) [@running\_coach](https://boards.straightdope.com/u/running_coach)\
**Post date:** [March 12, 2021, 8:26pm UTC](https://boards.straightdope.com/t/every-time-you-shuffle-a-deck-of-cards-the-sequence-has-never-existed-before/937719/41 "2021-03-12T20:26:34Z")

</div>

> [@Deeg](#):
>
> I’m sure that there are magicians who can take a set of cards and shuffle them in an exact order every time.

That would be [Ricky Jay.](https://www.youtube.com/watch?v=guKfJKh1tcA)

---

<div class="post-metadata">

**Author:** ![octopus](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/octopus/32/3716_2.png) [@octopus](https://boards.straightdope.com/u/octopus)\
**Post date:** [March 12, 2021, 8:27pm UTC](https://boards.straightdope.com/t/every-time-you-shuffle-a-deck-of-cards-the-sequence-has-never-existed-before/937719/42 "2021-03-12T20:27:56Z")

</div>

I was thinking of [Richard Turner (magician) - Wikipedia](https://en.wikipedia.org/wiki/Richard_Turner_(magician)).

---

<div class="post-metadata">

**Author:** ![mikecurtis](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/mikecurtis/32/3284_2.png) [@mikecurtis](https://boards.straightdope.com/u/mikecurtis)\
**Post date:** [March 12, 2021, 8:28pm UTC](https://boards.straightdope.com/t/every-time-you-shuffle-a-deck-of-cards-the-sequence-has-never-existed-before/937719/43 "2021-03-12T20:28:41Z")

</div>

Yup

[![](https://img.youtube.com/vi/TwFIJyWKs1k/maxresdefault.jpg "Fool Us - Richard Turner Thoroughly Astonishes Penn & Teller") ](https://www.youtube.com/watch?v=TwFIJyWKs1k)

---

<div class="post-metadata">

**Author:** ![k9bfriender](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/k9bfriender/32/3283_2.png) [@k9bfriender](https://boards.straightdope.com/u/k9bfriender)\
**Post date:** [March 12, 2021, 8:34pm UTC](https://boards.straightdope.com/t/every-time-you-shuffle-a-deck-of-cards-the-sequence-has-never-existed-before/937719/44 "2021-03-12T20:34:08Z")

</div>

If you did a fair shuffle, and the cards ended up in order, that’s still random.

Assuming that there was no funny business

> **[South Africa's lottery probed as 5, 6, 7, 8, 9 and 10 drawn and 20 win](https://www.bbc.com/news/world-africa-55154525)**
>
> Twenty ticketholders win in South Africa after the unusual sequence, sparking claims of fraud.

5,6,7,8,9,10 are just as random as 17, 18, 37, 44, 53

[https://www.powerball.com/](https://www.powerball.com/)

---

<div class="post-metadata">

**Author:** ![Ynnad](https://avatars.discourse-cdn.com/v4/letter/y/4491bb/32.png) [@Ynnad](https://boards.straightdope.com/u/Ynnad)\
**Post date:** [March 13, 2021, 2:39am UTC](https://boards.straightdope.com/t/every-time-you-shuffle-a-deck-of-cards-the-sequence-has-never-existed-before/937719/45 "2021-03-13T02:39:12Z")

</div>

> [@Hari\_Seldon](#):
>
> … What they showed was that 7 shuffles puts the deck withing [_sic_] 1% of being truly random. …

That’s probably close enough for real world card players. But is it even possible to get a deck, especially a brand new deck, to a _completely_ random state by _physical_ shuffling in a finite amount of time? ( **wolfpup** ’s proposed shuffling machine using a pseudo-random number generator and random seed to _assign_ the order of the cards is excluded for the purpose of this question.) The video in the OP says that 52! applies “after properly shuffling” a deck, whatever the heck that means.

---

<div class="post-metadata">

**Author:** ![Lantern2](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/lantern2/32/3010_2.png) [@Lantern2](https://boards.straightdope.com/u/Lantern2)\
**Post date:** [March 13, 2021, 9:06am UTC](https://boards.straightdope.com/t/every-time-you-shuffle-a-deck-of-cards-the-sequence-has-never-existed-before/937719/46 "2021-03-13T09:06:40Z")

</div>

> [@DPRK](#):
>
> > [@Lantern2](#):
> >
> > BTW I was looking at this factorial [table](https://www.mymathtables.com/numbers/100-factorial-tables-chart.html) and I discovered a neat pattern. 5! equals 120 the first one ending in zero. Then 10! ends in 2 zeroes, 15! in 3 zeroes and so on. However at 25! you go from 4 zeroes to 6 zeroes. After that 30! ends on 7 zeroes, 35! in 8 zeroes and so on. Again at 50! you get a double-jump from 10 to 12 zeroes and again at 75!. I imagine this pattern continues and perhaps at 125! there is a triple jump and a quadruple jump at 625! ?
> > 
> > Is there a theorem which explores this pattern?
> 
> Well, the number of zeroes is the number of times 10 goes into the factorial. So each power of 5 contributes that many zeros; there are at least that many 2’s.
> 
> I mean ⌊n/5⌋ + ⌊n/25⌋ + ⌊n/125⌋ + … after counting them.

Thanks. That makes a lot of sense.

---

<div class="post-metadata">

**Author:** ![Yosh99](https://avatars.discourse-cdn.com/v4/letter/y/ccd318/32.png) [@Yosh99](https://boards.straightdope.com/u/Yosh99)\
**Post date:** [March 13, 2021, 5:32pm UTC](https://boards.straightdope.com/t/every-time-you-shuffle-a-deck-of-cards-the-sequence-has-never-existed-before/937719/47 "2021-03-13T17:32:16Z")

</div>

I remember as a kid seeing an episode of “I’ve Got a Secret” where four contestants’ secret was that they had all been deal a perfect bridge hand, that is, everyone got the complete set of 13 cards from each suit.

I guess that was unlikely.

---

<div class="post-metadata">

**Author:** ![Hari\_Seldon](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/hari_seldon/32/5173_2.png) [@Hari\_Seldon](https://boards.straightdope.com/u/Hari_Seldon)\
**Post date:** [March 13, 2021, 9:14pm UTC](https://boards.straightdope.com/t/every-time-you-shuffle-a-deck-of-cards-the-sequence-has-never-existed-before/937719/48 "2021-03-13T21:14:29Z")

</div>

I should have said 7 _random_ shuffles gets within 1% of random. Time for some definitions. What is a random shuffle? Divide the deck at a random place, just so long as there are two piles. Get a table of random bits and look at the first bit. If it is a 0, take a card from the left pile and if a 1 take one from the right. Repeat until one pile is exhausted and then take all the cards from the remaining pile. Note that all the cards in the first pile are in the same order _relative to each other_ and the same is true of the cards in the second pile. That property is actually the formal definition of a shuffle. But it illustrates why one shuffle does not produce a random arrangement (nor do 7 or even 52!). The top card of the deck has a 50-50 chance of remaining the top and similarly for the bottom. And even after 7 shuffles, I would expect the top card has a much greater than average shot at staying in the top half and virtually none of ending up at the bottom.

Here is one way to get a truly random deck. Start with a table of random bits. I leave it to you to generate it. I once read of something involving a lava lamp. Which might not be really random, who knows. Take the first six as a binary number in the range 0-63. Discard it if it is 0 or \> 52 and choose the card in that position first. Choose the next 6 bits, only now you discard if it is 0 or \> 51. Rinse and repeat until you have exhausted the deck. I guess once you are down to 31 cards you can use only 5 bits and so on.

---

<div class="post-metadata">

**Author:** ![Lucas\_Jackson](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/lucas_jackson/32/303_2.png) [@Lucas\_Jackson](https://boards.straightdope.com/u/Lucas_Jackson)\
**Post date:** [March 13, 2021, 9:26pm UTC](https://boards.straightdope.com/t/every-time-you-shuffle-a-deck-of-cards-the-sequence-has-never-existed-before/937719/49 "2021-03-13T21:26:59Z")

</div>

I’ve been thinking of starting this thread for the last several months. You saved me the trouble! Ha ha.

---

<div class="post-metadata">

**Author:** ![markn\_1](https://avatars.discourse-cdn.com/v4/letter/m/f9ae1b/32.png) [@markn\_1](https://boards.straightdope.com/u/markn_1)\
**Post date:** [March 13, 2021, 9:29pm UTC](https://boards.straightdope.com/t/every-time-you-shuffle-a-deck-of-cards-the-sequence-has-never-existed-before/937719/50 "2021-03-13T21:29:02Z")

</div>

> [@Hari\_Seldon](#):
>
> I once read of something involving a lava lamp.

That was probably [LavaRand](https://en.wikipedia.org/wiki/Lavarand), an interesting idea but not very practical for widespread use. But there are many types of commodity hardware random number generators that use stuff like diode noise and do a pretty good job.

---

<div class="post-metadata">

**Author:** ![Chronos](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/chronos/32/134_2.png) [@Chronos](https://boards.straightdope.com/u/Chronos)\
**Post date:** [March 13, 2021, 9:49pm UTC](https://boards.straightdope.com/t/every-time-you-shuffle-a-deck-of-cards-the-sequence-has-never-existed-before/937719/51 "2021-03-13T21:49:09Z")

</div>

Note that a pseudorandom number generator will only produce a good shuffle if the seed is hundreds of bits long. You can only produce as many orderings as you have possible seeds, and the number of possible seeds in most implementations is going to be far less than 52! .

And I did, once, do a calculation of an actual physical quantity, in normal units, that came out to more than a googol. The largest known black holes in the Universe would take around 10^103 seconds to completely evaporate via Hawking radiation.

---

<div class="post-metadata">

**Author:** ![markn\_1](https://avatars.discourse-cdn.com/v4/letter/m/f9ae1b/32.png) [@markn\_1](https://boards.straightdope.com/u/markn_1)\
**Post date:** [March 13, 2021, 9:55pm UTC](https://boards.straightdope.com/t/every-time-you-shuffle-a-deck-of-cards-the-sequence-has-never-existed-before/937719/52 "2021-03-13T21:55:04Z")

</div>

To get more than 52! seed values, your seed would only need to be about 225 bits long. That’s actually a fairly short seed for a RNG, at least in cryptographic contexts, which often use 1024 bits or more.

---

<div class="post-metadata">

**Author:** ![wolfpup](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/wolfpup/32/10618_2.png) [@wolfpup](https://boards.straightdope.com/u/wolfpup)\
**Post date:** [March 13, 2021, 10:08pm UTC](https://boards.straightdope.com/t/every-time-you-shuffle-a-deck-of-cards-the-sequence-has-never-existed-before/937719/53 "2021-03-13T22:08:20Z")

</div>

> [@Chronos](#):
>
> Note that a pseudorandom number generator will only produce a good shuffle if the seed is hundreds of bits long. You can only produce as many orderings as you have possible seeds, and the number of possible seeds in most implementations is going to be far less than 52! .

But if you had a guaranteed non-repeating pseudo-random number generator, you could save its state after each run, and thus continue from the previous state. Now granted, its state would be quite a large amount of data, but it would be easily manageable – you would not need a seed of size (52!) to generate an arbitrarily large sequence of unique card deck permutations.

---

<div class="post-metadata">

**Author:** ![wolfpup](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/wolfpup/32/10618_2.png) [@wolfpup](https://boards.straightdope.com/u/wolfpup)\
**Post date:** [March 14, 2021, 11:04am UTC](https://boards.straightdope.com/t/every-time-you-shuffle-a-deck-of-cards-the-sequence-has-never-existed-before/937719/54 "2021-03-14T11:04:31Z")

</div>

> [@markn\_1](#):
>
> To get more than 52! seed values, your seed would only need to be about 225 bits long. That’s actually a fairly short seed for a RNG, at least in cryptographic contexts, which often use 1024 bits or more.

That’s a good point that I hadn’t noticed earlier. I think you would actually need 226 bits, as 225 falls slightly short of (52!), but in any case, as vast a number as (52!) is, it doesn’t take that many bits to contain it – 29 bytes is more than enough. If there’s some technical difficulty with getting a random seed that large, as long as you had a truly random source, you could just do successive fetches, even if it just delivered a byte at a time.

---

<div class="post-metadata">

**Author:** ![Chronos](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/chronos/32/134_2.png) [@Chronos](https://boards.straightdope.com/u/Chronos)\
**Post date:** [March 14, 2021, 12:09pm UTC](https://boards.straightdope.com/t/every-time-you-shuffle-a-deck-of-cards-the-sequence-has-never-existed-before/937719/55 "2021-03-14T12:09:24Z")

</div>

But unless your PRNG, and the shuffling algorithm based on it, had some very specific properties, you could (and in fact very likely would) get some instances of matching shuffles from non-matching seeds. Which would then imply that you’d be missing some others. You’d need many more possible seeds to be reasonably assured of hitting every possible shuffle even once. And even then, no algorithm with a seed composed of a set number of bits would ever hit every possible shuffle the same number of times, as would be necessary for a truly random shuffle.

---

<div class="post-metadata">

**Author:** ![wolfpup](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/wolfpup/32/10618_2.png) [@wolfpup](https://boards.straightdope.com/u/wolfpup)\
**Post date:** [March 14, 2021, 12:51pm UTC](https://boards.straightdope.com/t/every-time-you-shuffle-a-deck-of-cards-the-sequence-has-never-existed-before/937719/56 "2021-03-14T12:51:36Z")

</div>

> [@Chronos](#):
>
> And even then, no algorithm with a seed composed of a set number of bits would ever hit every possible shuffle the same number of times, as would be necessary for a truly random shuffle.

I get your point, but its validity depends on how you define “random”. If you define it in terms of process, agreeing that the process is unpredictable and hence effectively random, then you have to accept whatever it spits out, which may be statistically flawed. Or you can define it in terms of output, _ **requiring** _ it to have a statistically random distribution over some set interval. Which is your second definition.

I think it’s fair to say that all real-world RNGs and PRNGs are of the first type. But I think it only means that the distribution is not statistically uniform. Assuming a fantastically long run time (or fantastically fast shuffling) although you may get repeated card arrangements and others may not appear for a very long time, I don’t see it as axiomatic that you will not eventually get all possible card arrangements, even with a single seed, provided you ran it long enough. Heck, you could probably do it with just a long enough series of the digits of pi.

I think the problem with saying that you get some matching shuffles from non-matching seeds and therefore you’d be missing some others is that it assumes an output series of some predefined finite length. I’m assuming it runs as long as necessary until it produces all required permutations of the card deck. Like the digits of pi, as long as it doesn’t repeat, you’ll eventually get there.

(I am not a mathematician and some of my assumptions here might be wrong.)

---

<div class="post-metadata">

**Author:** ![Crane](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/crane/32/3495_2.png) [@Crane](https://boards.straightdope.com/u/Crane)\
**Post date:** [March 14, 2021, 2:25pm UTC](https://boards.straightdope.com/t/every-time-you-shuffle-a-deck-of-cards-the-sequence-has-never-existed-before/937719/57 "2021-03-14T14:25:09Z")

</div>

I don’t see the significance of using a PNG. Early single chip computers used PNGs for instruction counters. The instructions did not reside in adjacent memory locations but they were executed in the same sequence as if the counter had been linear. So, there is no long term statistical difference between using a linear sequence or a PNG sequence.

Also, if you are imposing a method that eliminates the possibility of repeating sequences, is the process random?

---

<div class="post-metadata">

**Author:** ![RickJay](https://avatars.discourse-cdn.com/v4/letter/r/bb73d2/32.png) [@RickJay](https://boards.straightdope.com/u/RickJay)\
**Post date:** [March 14, 2021, 2:32pm UTC](https://boards.straightdope.com/t/every-time-you-shuffle-a-deck-of-cards-the-sequence-has-never-existed-before/937719/58 "2021-03-14T14:32:56Z")

</div>

> [@pulykamell](#):
>
> I don’t understand this. Are you assuming a one-pass shuffle with no cutting and rearranging? When I think of a shuffle, I think of a few riffles, a few hand-over-hand passes, a few riffles, and then maybe a cut to end. To me, to “shuffle a deck of cards” means not one-pass, but something like that.

Well, I play poker, and that ain’t a shuffle. A “shuffle” is a genuine randomization.

---

<div class="post-metadata">

**Author:** ![RickJay](https://avatars.discourse-cdn.com/v4/letter/r/bb73d2/32.png) [@RickJay](https://boards.straightdope.com/u/RickJay)\
**Post date:** [March 14, 2021, 2:37pm UTC](https://boards.straightdope.com/t/every-time-you-shuffle-a-deck-of-cards-the-sequence-has-never-existed-before/937719/59 "2021-03-14T14:37:48Z")

</div>

> [@Ynnad](#):
>
> That’s probably close enough for real world card players. But is it even possible to get a deck, especially a brand new deck, to a _completely_ random state by _physical_ shuffling in a finite amount of time? ( **wolfpup** ’s proposed shuffling machine using a pseudo-random number generator and random seed to _assign_ the order of the cards is excluded for the purpose of this question.) The video in the OP says that 52! applies “after properly shuffling” a deck, whatever the heck that means.

As to this, you can get closer to true random through such common conventions as washing the deck (spreading it out on the table and shuffling cards around randomly before assembling the deck) prior to a standard riffle/cut procedure.

A proper shuffle isn’t just a couple of riffles, or even just one means of shuffling; the deck should be riffled, cut multi ways, and riffled some more. If using a mechanical shuffler, it should be cut before and after use of the shuffler.

---

<div class="post-metadata">

**Author:** ![wolfpup](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/wolfpup/32/10618_2.png) [@wolfpup](https://boards.straightdope.com/u/wolfpup)\
**Post date:** [March 14, 2021, 2:58pm UTC](https://boards.straightdope.com/t/every-time-you-shuffle-a-deck-of-cards-the-sequence-has-never-existed-before/937719/60 "2021-03-14T14:58:05Z")

</div>

> [@Crane](#):
>
> I don’t see the significance of using a PNG. Early single chip computers used PNGs for instruction counters. The instructions did not reside in adjacent memory locations but they were executed in the same sequence as if the counter had been linear. So, there is no long term statistical difference between using a linear sequence or a PNG sequence.

This makes no sense to me. Non-sequentially located instructions that are executed sequentially are essentially a linked list, ordered in logical sequence rather than physical sequence, with each instruction containing the address of the next one. This was the case with early computers with drum memories, but the locations were not “random”, they were optimized to minimize drum rotational latency. I have no idea what any of this has to do with random number sequences. Maybe this wasn’t a response to me and you were referring to something else?

> [@Crane](#):
>
> Also, if you are imposing a method that eliminates the possibility of repeating sequences, is the process random?

With reference to what I was writing, that’s not what I meant by “as long as it doesn’t repeat”. Obviously any random series is going to have some repeating sequences of finite length. I meant that it didn’t loop, such that after a given sequence it always started all over again. Which would simply be a defective random number generator.

[Previous page](https://boards.straightdope.com/t/every-time-you-shuffle-a-deck-of-cards-the-sequence-has-never-existed-before/937719.md?page=2)

[Next page](https://boards.straightdope.com/t/every-time-you-shuffle-a-deck-of-cards-the-sequence-has-never-existed-before/937719.md?page=4)
