Shuffle again and again and again...

In group theory, if you take a standard deck of cards and shuffle it exactly the same way repeatedly, you will eventually get back to the original order of the cards. For a standard deck of 52 cards, this could take many deck shufflings!

However, what if your deck consisted of only 8 cards?

With only 8 cards, what is the smallest number of identical shufflings you need to make in order to be guaranteed to return to the original order of the cards (somewhere along the way)?

Assumption: All shuffles are identical. For example, if the first shuffle takes the third card to the fifth position, then all successive shuffles will also take the third card to the fifth position. Or, more generally, for all n n , if the n th n^\text{th} card went to the m th m^\text{th} position, then the n th n^\text{th} card would necessarily go to the m th m^\text{th} position on all successive shufflings.

Clarification: . You don't get to pick the way the cards are shuffled, but they must be shuffled the same way every time.


The answer is 15.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

8 solutions

Arjen Vreugdenhil
Sep 23, 2018

An interesting question is how this applies to a deck of n n cards.

Any permutation σ S n \sigma \in S_n can be written uniquely (up to commutative swapping of the factors) as the product of disjoint cycles. The sum of lengths of these cycles is obviously n n or less. The index σ |\sigma| (i.e. the smallest power k > 0 k > 0 for which σ k = id \sigma^k = \text{id} ) is equal to the least common multiple of the cycle lengths: σ = i = 1 m C i σ = lcm ( C 1 , , C m ) . \sigma = \prod_{i = 1}^m C_i\ \ \ \ \ \therefore\ \ \ \ \ \ |\sigma| = \text{lcm}(|C_1|, \dots, |C_m|). This number k k is the smallest number of shuffles of type σ \sigma after which the deck returns to its original state.

To answer the question, then, we need to find the maximum of these least common multiples k k : max σ S n σ . \max_{\sigma \in S_n} |\sigma|. To find this maximum, we don't need to consider all σ \sigma ; it is sufficient to work with the cycle structure, i.e. we consider all unordered lists (bags) c 1 , c 2 , , c m such that c i n . \langle c_1, c_2, \dots, c_m \rangle \ \ \ \ \text{such that}\ \sum c_i \leq n. Now suppose that c j = a b c_j = a\cdot b for coprime numbers a , b > 1 a,b > 1 . Then it pays to replace c j c_j by two values a a and b b : after all, this does not change the lcm but it does reduce the sum c i \sum c_i , allowing for the addition of more cycles. Therefore we can choose all c i c_i to be powers of prime numbers. Obviously, there is no advantage of having two powers of the same prime number; removing the smaller of the two does not change the lcm.

Thus we need only consider set p 1 e 1 , , p m e m \langle p_1^{e_1}, \dots, p_m^{e_m} \rangle consisting of powers of distinct primes, whose sum is less than n n .

For n = 8 n = 8 , we consider sets chosen from one or more of the sets { 2 , 4 , 8 } \{ 2,4,8\} ; { 3 } \{3\} ; and { 5 } \{5\} : 8 = 8 ; 4 3 = 12 ; 2 5 = 10 ; 3 5 = 15 . 8 = 8;\ \ \ 4\cdot 3 = 12;\ \ \ 2\cdot 5 = 10;\ \ \ 3\cdot 5 = \boxed{15}. This maximum number of 15 shuffles is obtained by any permutation of the form σ = ( a 1 a 2 a 3 ) ( b 1 b 2 b 3 b 4 b 5 ) \sigma = (a_1\ a_2\ a_3)\ (b_1\ b_2\ b_3\ b_4\ b_5) , where all a i a_i and b i b_i are distinct.

For n = 52 n = 52 , the situation is more interesting. The cycle lengths of interest are { 2 , 4 , 8 , 16 , 32 } ; { 3 , 9 , 27 } ; { 5 , 25 } ; { 7 , 49 } ; { 11 } ; { 13 } ; { 17 } ; { 19 } ; { 23 } ; { 29 } ; { 31 } ; { 37 } ; { 41 } ; { 43 } ; { 47 } . \{2,4,8,16,32\};\ \{3,9,27\};\ \{5,25\};\ \{7,49\};\ \{11\};\ \{13\};\ \{17\};\ \{19\};\ \{23\};\ \{29\};\ \{31\};\ \{37\};\ \{41\};\ \{43\};\ \{47\}. We can have no more than one of the last six primes. Exploring the possibilities (e.g. using computer code) we find the cycle structure 4 , 5 , 7 , 9 , 11 , 13. 4,5,7,9,11,13. Thus, for a complete set of cards the maximum number of shuffles is 180 180 180\:180 , using a permutation of the form ( a 1 a 2 a 3 a 4 ) ( b 1 b 5 ) ( c 1 c 7 ) ( d 1 d 9 ) ( e 1 e 11 ) ( f 1 f 13 ) ( o 1 ) ( o 2 ) ( o 3 ) , (a_1\ a_2\ a_3\ a_4)\ (b_1\ \dots\ b_5)\ (c_1\ \dots\ c_7)\ (d_1\ \dots\ d_9)\ (e_1\ \dots\ e_{11})\ (f_1\ \dots\ f_{13})\ (o_1)\ (o_2)\ (o_3), where the 52 indices mentioned are all distinct. (The three cards o 1 , o 2 , o 3 o_1, o_2, o_3 remain in place in each shuffle.)

Or you can look up information on Landau's function g g , since this question is simply asking for g ( 8 ) g(8) .

Mark Hennings - 2 years, 8 months ago

Log in to reply

Look at that, the function has a name! I was not aware of the Landau function. Thanks.

Arjen Vreugdenhil - 2 years, 8 months ago

If I take card 1 to possition 2 I shuffeled it once. If then I take card 2 (now card 1) to position 3 (now position 2) I shuffeled it twice and the order is the same. Why isn't teice shuffeling correct?

x y - 1 year, 4 months ago

Log in to reply

2 shuffles would make this type of shuffle orginal but not all. But if you shuffled it 15,30,.... Then no matter what the shuffle pattern was, you would surely have the original deck.

Michael De Santa - 1 year, 3 months ago
Geoff Pilling
Sep 15, 2018

Consider this shuffling:

12345678 23451786 12345678 \to 23451786

This would take 15 shuffles to return to the first position, since you have two "loops" of 3 and 5 which are coprime. Each loop returns to their original position after every 3 and 5 turns. So, the total number of shuffles needed would be 5 3 = 15 5 \cdot 3 = 15

Now, to show that this is the worst case... Well, 3 and 5 are the coprime numbers that add up to 8, that yield the largest product, therefore I believe this is the worst you can do.

Nice question. This is known as Landau's function . The minimum number of shuffles for 8 cards would be 6.

Brian Charlesworth - 2 years, 8 months ago

Log in to reply

Interesting... This is the first I've heard of Landau's function... I wonder though... What is meant by the minimum number of shuffles and how do you come up with the number 6?

Geoff Pilling - 2 years, 8 months ago

Log in to reply

Hmm, sorry, I guess I was thinking of the number of perfect interleaving shuffles that returns the deck to its original state, (and even there the number for 8 cards would be 3 perfect shuffles, not 6), which is not the same scenario you've posed.

P.S.. The maximum for 52 cards is 180180. :O

Brian Charlesworth - 2 years, 8 months ago

Shouldn't the answer be 840 given the shuffle could be any of the permutations in the group S8: (8),(1)(7),(3)(5), (4)(4), ect. where n in (n) describes the order of the cycle. I guess what I'm saying is that if you where to randomly pick a way to shuffle the cards (a permutation), you would have to shuffle them identically 840 times to be guaranteed that you return to the original order. For example, if you were to randomly choose a shuffling or permutation, and you got (1)(7), but you were to shuffle the deck 15 identical times, the deck would not be in the original order since 7 does not divide 15. And the lcm(8,3,5,7) is 840. Is that wrong?

Brent Baillie - 2 years, 8 months ago

Log in to reply

Ah good point, Brent.... Lemme think about how to clarify the question...

Geoff Pilling - 2 years, 8 months ago

‘Least number of shuffles to guarantee return to starting point’ led me to the 840 answer. If you don’t know the permutation then it would take 840 shuffles to cover off all the possibilities. I can’t think of an elegant way to phrase the question that forces you to the answer of 15. Maybe ‘what are the maximum number of shuffles possible before cards return to the starting position for the first time?’. Your question as it is is better. It’s just that the answer is 840 ;-)

William Downing - 2 years, 8 months ago

Log in to reply

Thanks for your input... I agree. The 840 answer is much more interesting. In hindsight I should have likely rephrased the question a bit... I have well, maybe next time...

Geoff Pilling - 2 years, 8 months ago

https://oeis.org/A000793

Jeremy Galvagni - 2 years, 8 months ago

I know this is too naive, but why can't the shuffle 12345678 ==> 56781234 be considered? This would recover the initial configuration after two shuffles. Isn't it a shuffle?

Stefano Micheletti - 2 years, 8 months ago

Log in to reply

This would indeed count as a shuffle and would return to the original position in two shuffles. However the problem stipulates that you can't choose the shuffle.

Geoff Pilling - 2 years, 8 months ago

Log in to reply

OK, I can't choose the shuffle, but if that's is a shuffle (and you are confirming that), among all shuffles, I eventually have to come across that particular shuffle. Is the problem actually asking what's the best shuffle (in terms of number of steps to return to the original configuration) or is it asking a kind of "min max" or "max min"? But I can't figure out what this min max or max min refer to.

Stefano Micheletti - 2 years, 8 months ago

Log in to reply

@Stefano Micheletti The question is actually asking for the absolute max.

As for the min: that would be 1. 12345678==>12345678

Jeremy Galvagni - 2 years, 8 months ago
Mark Hennings
Sep 22, 2018

We want to know the largest order of an element of the permutation group S 8 S_8 . To do this, we must know the various cycle types of elements of S 8 S_8 . These are 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 2 × 2 , 2 × 3 , 2 × 4 , 2 × 5 , 2 × 6 , 3 × 3 , 3 × 4 , 3 × 5 , 4 × 4 , 2 × 2 × 2 , 2 × 2 × 3 , 2 × 2 × 4 , 2 × 3 × 3 , 2 × 2 × 2 × 2 1,2,3,4,5,6,7,8,2\times2,2\times3,2\times4,2\times5,2\times6,3\times3,3\times4,3\times5,4\times4,2\times2\times2,2\times2\times3,2\times2\times4,2\times3\times3,2\times2\times2\times2 and these cycle types have orders 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 2 , 6 , 4 , 10 , 6 , 3 , 12 , 15 , 4 , 2 , 6 , 4 , 6 , 2 1,2,3,4,5,6,7,8,2,6,4,10,6,3,12,15,4,2,6,4,6,2 respectively. Thus the elements of S 8 S_8 with the largest order are the 3 × 5 3\times5 cycles, and hence the largest possible order is 15 \boxed{15} .

Binky Mh
Sep 26, 2018

A card will always follow a cycle of positions in the deck. For example, if only card 1 1 is moved to position 3 3 , the cycle would be 1 1 , 3 3 , 2 2 , and then back to 1 1 .

All cards within a cycle will take the same number of shuffles before returning to their starting positions. In the example above, cards 1 1 , 2 2 and 3 3 will return to their starting positions after 3 3 shuffles.

The number of shuffles it takes to return the entire deck to its starting position is the lowest common multiple of all cycles. For example, in a larger deck with cycles of 4 4 , 6 6 and 10 10 , the number of shuffles would be 60 60 .

The set of numbers which sum to 8 8 , and whose l c m lcm is highest, is 3 3 and 5 5 , resulting in a shuffle count of 15 \boxed{15} .

I think the problem is not well expressed.

It is written: "(...) what is the largest number of identical shufflings you need (...)"

With 15 shuffles you are guaranteed to return to the original order (somewhere along the way). With 16 shuffles you also are guaranteed, because you are with 15.

To me, 15 is a lower limit, not upper. So the problem should be: "(...) what is the smallest number of identical shufflings you need (...)"

Edit: corrected! My first contribute into this community ^_^

João Maldonado
Sep 26, 2018

This problem gets very easy if you think this way. You have a bijection between the numbers 1 to 8. Suppose you have no other bijection inside this one (i.e. if 1, 2 and 3 form a loop, then you have a bijection between these numbers), then after 8 turns you will get the same deck again. However you can have 2 or more bijections. Suppose you have 2 loops, one with 5 numbers and the other with 3. You will get the same deck after 15 shuffles. The number of shuffles that will get you the same deck is the lcm of the loop sizes.

With 1 loop you have 8 shuffles maximum

With 2 loops you have lcm(3,5) = 15

With 3 loops you have lcm(3,4,1)=12

With 4 loops you have lcm(3,2,2)=6

With 5 o more the loops will have length of 4 or less, since 16 is impossible the lcm is not bigger than 15

So the answer is 15.

Malcolm Rich
Sep 25, 2018

If one were to apply this as some sort of trick, then one alternative question is the smallest number required for any perfect shuffle to return to the starting position. In other words, the cards are shuffled n times and then revealed to be in their original order.

I believe this would require 840 shuffles.

I think the question as it is exposed now is trickier.

Michele Chiminazzo - 2 years, 8 months ago
Vinod Kumar
Sep 25, 2018

Landau's function g(8)=15 is the Answer.

Here, g(n) is the largest least common multiple (lcm) of any partition of n ( for n=8, 5+3=8, 5×3=15) , or the maximum number of times a permutation of n elements can be recursively applied to itself before it returns to its starting sequence.

Read more about Landau's function here:

https://en.m.wikipedia.org/wiki/Landau%27s_function

Check integer sequence A000793 in the OEIS named after Edmund Landau for g(n).

Answer=15

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...