I used to host weekly poker games. Nothing too serious. 5/10 cent blinds, beer, and shenanigans. One thing I picked up from those times that I still do is play with poker chips. I always have a stack at my desk that I play with or shuffle while I'm working or thinking. Kinda like a fidget toy.
Today, as I was shuffling a stack with an equal number of different colored chips, I noticed different patterns in the stack after each shuffle, and If I shuffled enough they'd end up how they started. For instance, if there were seven of each color and they started out grouped by color, it took four perfect shuffles for them to be grouped by color again.
This made me wonder how the number of required shuffles would change based on the number of chips in the stack. So… I started shuffling stacks and made a table showing the relationship between number of chips and number of shuffles.
# of each color | shuffles to regroup | shuffles to original |
---|---|---|
1 | 1 | 2 |
2 | 2 | 4 |
3 | 3 | 3 |
4 | 3 | 6 |
5 | 5 | 10 |
6 | 6 | 12 |
7 | 4 | 4 |
8 | 4 | 8 |
9 | 9 | 9 |
I naively expected to be able to recognize a pattern but after eight iterations, I was nowhere close to understanding what was going on, and as the stack of poker chips grew larger, the harder it became to shuffle them consistently. So… I wrote a bit of software to emulate what the shuffles were doing. Check it out.
I ran the model for stacks from 6 to 40 chips and saw no obvious pattern. I tried 100 chips, then 1,000 chips, then 2,000, then 10,000. (Here's the data if you dare to care.) I even plotted a graph for a visually aid.
Almost 6,000 chip shuffle models.
While I could see lines and patterns in the graph, I was no closer to identifying a predictable pattern. A mathematician might look at this and be able to know what's going on, but a mathematician I am not.
I recalled seeing someone shuffle an ordered deck of cards in such a way that after several shuffles it returned to it's orginal order. A quick googly taught me this was called "faro shuffle", and the mathematics behind it are pretty much the same as my poker chip shuffles! I found a paper published in 1983 titled "The Mathematics of Perfect Shuffles" by Diaconis, Graham, and Kantor which contained the answers I was looking for. I read just enough of this paper to satisfy my tiny brain's curiosity and moved on.
The biggest difference between my poker chip shuffle problem and the faro shuffle problem, is that I stopped when the poker chips were yet again grouped by color, not necessarily in it's original order. So in many cases it took half the amount of shuffles as it would have to restore it to its original state. For instance when there are 8 white chips and 8 brown chips, it takes 4 shuffles for them to be grouped by color again, though while the white chips started on the bottom, they ended on the top. Another 4 shuffles would restore the stack to it's original state.
I read (barely) a mathematics paper today, watched a nice lady explain cycles and permutations, and learned new terms like "combinatorics". And, while I still have questions my curiosity has been quelched for now. I'll probably bring this up one night after a few beers and not be able to explain it all.