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 , if the n th card went to the m th position, then the n th card would necessarily go to the m 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.
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.
Or you can look up information on Landau's function g , since this question is simply asking for g ( 8 ) .
Log in to reply
Look at that, the function has a name! I was not aware of the Landau function. Thanks.
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?
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.
Consider this shuffling:
1 2 3 4 5 6 7 8 → 2 3 4 5 1 7 8 6
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 = 1 5
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.
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?
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
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?
Log in to reply
Ah good point, Brent.... Lemme think about how to clarify the question...
‘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 ;-)
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...
https://oeis.org/A000793
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?
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.
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.
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
We want to know the largest order of an element of the permutation group S 8 . To do this, we must know the various cycle types of elements of 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 and these cycle types have orders 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 2 , 6 , 4 , 1 0 , 6 , 3 , 1 2 , 1 5 , 4 , 2 , 6 , 4 , 6 , 2 respectively. Thus the elements of S 8 with the largest order are the 3 × 5 cycles, and hence the largest possible order is 1 5 .
A card will always follow a cycle of positions in the deck. For example, if only card 1 is moved to position 3 , the cycle would be 1 , 3 , 2 , and then back to 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 , 2 and 3 will return to their starting positions after 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 , 6 and 1 0 , the number of shuffles would be 6 0 .
The set of numbers which sum to 8 , and whose l c m is highest, is 3 and 5 , resulting in a shuffle count of 1 5 .
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 ^_^
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.
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.
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
Problem Loading...
Note Loading...
Set Loading...
An interesting question is how this applies to a deck of n cards.
Any permutation σ ∈ 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 or less. The index ∣ σ ∣ (i.e. the smallest power k > 0 for which σ k = id ) is equal to the least common multiple of the cycle lengths: σ = i = 1 ∏ m C i ∴ ∣ σ ∣ = lcm ( ∣ C 1 ∣ , … , ∣ C m ∣ ) . This number k is the smallest number of shuffles of type σ 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 : σ ∈ S n max ∣ σ ∣ . To find this maximum, we don't need to consider all σ ; 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 . Now suppose that c j = a ⋅ b for coprime numbers a , b > 1 . Then it pays to replace c j by two values a and b : after all, this does not change the lcm but it does reduce the sum ∑ c i , allowing for the addition of more cycles. Therefore we can choose all 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 ⟩ consisting of powers of distinct primes, whose sum is less than n .
For n = 8 , we consider sets chosen from one or more of the sets { 2 , 4 , 8 } ; { 3 } ; and { 5 } : 8 = 8 ; 4 ⋅ 3 = 1 2 ; 2 ⋅ 5 = 1 0 ; 3 ⋅ 5 = 1 5 . 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 ) , where all a i and b i are distinct.
For n = 5 2 , the situation is more interesting. The cycle lengths of interest are { 2 , 4 , 8 , 1 6 , 3 2 } ; { 3 , 9 , 2 7 } ; { 5 , 2 5 } ; { 7 , 4 9 } ; { 1 1 } ; { 1 3 } ; { 1 7 } ; { 1 9 } ; { 2 3 } ; { 2 9 } ; { 3 1 } ; { 3 7 } ; { 4 1 } ; { 4 3 } ; { 4 7 } . 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 , 1 1 , 1 3 . Thus, for a complete set of cards the maximum number of shuffles is 1 8 0 1 8 0 , 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 1 1 ) ( f 1 … f 1 3 ) ( o 1 ) ( o 2 ) ( o 3 ) , where the 52 indices mentioned are all distinct. (The three cards o 1 , o 2 , o 3 remain in place in each shuffle.)