All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > General
Perfect Shuffle (Posted on 2004-05-19) Difficulty: 5 of 5
You have a deck of 52 cards - for convenience, number them 1 through 52. You cut the cards into two equal halves and shuffle them perfectly. That is, the cards were in the order
and now they are
1,27,2,28,...,26,52. Let's call this a perfect in-shuffle.

If you repeat this in-shuffling process, how many in-shuffles will it take for the deck to return to its initial ordering (taking for granted that the cards will eventually do so)?

How does the solution change if you have a deck of 64 cards, or 10, or in general, n cards? For odd integer values of n, in-shuffling will take 1,2,3,...,n to 1,(n+3)/2,2,(n+5)/2,...,n,(n+1)/2. For example, when n=5, the first in-shuffle yields 1,4,2,5,3.

No Solution Yet Submitted by SilverKnight    
Rating: 4.2500 (4 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Hints/Tips recursive observations | Comment 19 of 20 |

I came up with a recursive definition for the successive positions of a card while we shuffle it, and when we get the same x value as the input we should be done, ofcourse we should maintain a count of how many times we recursed through the function, this is how I found out the answer for the initial case of 52 cards and it is 8:

if the initial position of a card is say 'p' then we can have this function, here 'n' is the total number of cards;

f(x) = f(2x - 1) if x <= n/2

f(x) = f(2x - n) if x > n/2

stop recursing if x = p (not for the first time)

we will run this function with any 'p' less than n and find out f(p), we stop when 2x-1 or 2x-n get equal to p, the number of recursions through this function to arrive at the same 'p' accounts for the number of shuffles needed to get the pack to the initial position. I tried this function manually for a number of two digit numbers, but all were even, i am sure this can be modified to make it work for odd numbers, also i observed the pattern that for power of 2 the exponent is the number of shuffles needed for example for 32 five shuffles, for 64 six shuffles and so on.
  Posted by Ramakanth on 2004-07-18 20:24:33
Please log in:
Remember me:
Sign up! | Forgot password

Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (5)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Copyright © 2002 - 2018 by Animus Pactum Consulting. All rights reserved. Privacy Information