Visualizing what happens when you shuffle a deck of cards

Originally published at:


Not me! As a computer programmer, I roll a 52 sided die and swap the first card for the card number of the die roll. Then I do it for the 2d card, etc, until I get to the last card.

Where my nerd friends at?!


Really great data visualization. This man is living a good life.


I once made a spreadsheet to prove that after 8 perfect riffle shuffles, a 52-card deck is restored to its starting position. And I once got very good at riffle shuffling, but I never managed to pull off 8 perfect ones in a row. Retaining top stock is usually enough, though. Nice visualization.


It is probably easier to manage with a Faro shuffle.

1 Like

Well, yes, technically it is, but a Faro shuffle just looks suspicious, like it’s obvious you’re manipulating the cards. I’m still pretty good at perfect Faro shuffles, but I rarely use them.

Then I do it for the 2nd card,

You have to roll a 51-sided dice for the 2nd card if you really want a random shuffle. (And a 50-sided dice for the 3rd &c).


Your Nerd Friend.


What, you don’t have a factorial dice?


Maybe when you shuffle. When I do it, it’s a game of 52-pickup.


Gone home waiting for you to shuffle the deck. :wink:

1 Like



It’s like the butterfly operation that is used to calculate an FFT (fast Fourier transform).

1 Like

There are more ways to arrange a deck of cards than there are atoms in the Milkyway galaxy; 2-4 times more actually.


when I shuffle cards it’s more like the same 3 cards get swapped around a few times. (overhand shuffler)

Yes, that would be more efficient for the computer, but onerous IRL.
We can agree that I dumbed it down a hair for the sake of the hilarious comedy gold.

We can agree that you dumbed it down a hair for the sake of hilarious comedy gold. Good job.

But what are nerdy friends for if not to point out that the procedure you suggested isn’t a perfect shuffle. With your procedure, the 2nd card of the pre-shuffled deck ends up on top of the deck 80% more often than the last card ends up on top of the deck! The correct procedure is far more hilarious.

Would anyone like to suggest an actually effective method for shuffling a deck of cards with D&D dice, if you forgot to bring your D51? Bonus points if you can do it using only a D20.


p.s. verified with a quick C# program. To be honest, I expected the shuffle to be subtly bad. I was surprised to find out how bad it really was.

1 Like

This topic was automatically closed after 5 days. New replies are no longer allowed.