Find Function to fit data - Card shuffle

Routaran
Hello,
I had a chat with a person at work and we were discussing a card shuffle and what governed its behaviour. Here's the shuffle rules.
Have to use an even number of cards
Take top and bottom card and make new pile
the next top and bottom card go below the new pile

Here's an example of a shuffle with 4 cards
1,2,3,4 <-- Original
1,4,2,3 <-- 1st Shuffle
1,3,4,2 <-- 2nd Shuffle
1,2,3,4 <-- 3rd Shuffle

As you can see on the 3rd shuffle, the cards return to their original order. We are trying to predict, given an even number of cards, how many shuffles it will take for the cards to return to their original order.
I wrote a VB Console application and calculated for all even numbers between 2 up to 32768. I graphed the data on a scatter plot and found that there's an upper and lower boundary that all the data exists in and there's other patterns as well.
The upper boundary is given by: y=x-1
The lower boundary is given by: y= (log2 x) -1

But we weren't able to find a single function that was able to predict what the number of shuffles would be, given an even number of cards. Any ideas on how to solve this?

I've attached 2 files:
A tab delimited text file containing data for number of cards/number of shuffles for all even numbers from 2 up to 32768
The source (in visual basic - Console program) for the program I wrote to calculate values (to verify that I didn't screw up in the data generation)

Cheers,
Routaran

Attachments

• Shuffles_Data.txt
184.3 KB · Views: 761
• Shuffle_Source_VB.txt
6.1 KB · Views: 408

economicsnerd
If I understand correctly, you take input $$1,2,...,x-1,x$$ and give output $$1,x, 2,...,x-1.$$ If that's the case, it seems like your upper-boundary should always be how long it takes, i.e. $x-1$. Indeed, you're just leaving the first card where it is and cycling the other $x-1$.

Routaran
No, this doesn't apply to all possible numbers of cards. In my example i used 4 cards and it appears this way. If I use 10 cards and do the shuffle, it no longer follows this pattern.
10 card example:
Code:
1	2	3	4	5	6	7	8	9	10 <-- Original
1	10	2	9	3	8	4	7	5	6  <-- 1st Shuffle
1	6	10	5	2	7	9	4	3	8  <-- 2nd Shuffle
1	8	6	3	10	4	5	9	2	7  <-- 3rd Shuffle
1	7	8	2	6	9	3	5	10	4  <-- 4th Shuffle
1	4	7	10	8	5	2	3	6	9  <-- 5th Shuffle
1	9	4	6	7	3	10	2	8	5  <-- 6th Shuffle
1	5	9	8	4	2	6	10	7	3  <-- 7th Shuffle
1	3	5	7	9	10	8	6	4	2  <-- 8th Shuffle
1	2	3	4	5	6	7	8	9	10 <-- 9th Shuffle

economicsnerd
Okay, cool. That clarifies it.

So if $x=2n$, your shuffle takes $$t_1,...,t_n,b_n,...,b_1$$ to $$t_1,b_1,...,t_n,b_n.$$

Routaran
yes, this appears represents each successive shuffle correctly for any number of n

How do I go from this general representation to figuring out how many shuffles it will take to get the original state for any given n?