Find Function to fit data - Card shuffle

  • Thread starter Routaran
  • Start date
  • #1
Routaran
447
94
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

Answers and Replies

  • #2
economicsnerd
269
24
If I understand correctly, you take input [tex]1,2,...,x-1,x[/tex] and give output [tex]1,x, 2,...,x-1.[/tex] If that's the case, it seems like your upper-boundary should always be how long it takes, i.e. [itex]x-1[/itex]. Indeed, you're just leaving the first card where it is and cycling the other [itex]x-1[/itex].
 
  • #3
Routaran
447
94
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
 
  • #4
economicsnerd
269
24
Okay, cool. That clarifies it.

So if [itex]x=2n[/itex], your shuffle takes [tex]t_1,...,t_n,b_n,...,b_1[/tex] to [tex]t_1,b_1,...,t_n,b_n.[/tex]
 
  • #5
Routaran
447
94
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?
 

Suggested for: Find Function to fit data - Card shuffle

  • Last Post
Replies
2
Views
182
Replies
4
Views
536
  • Last Post
Replies
6
Views
390
Replies
3
Views
342
Replies
1
Views
394
  • Last Post
Replies
0
Views
242
Replies
64
Views
631
Replies
7
Views
169
  • Last Post
Replies
5
Views
499
Replies
19
Views
1K
Top