Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Perform an out shuffle on a list
ResourceFunction["OutShuffle"][list] performs an out shuffle on list. | |
ResourceFunction["OutShuffle"][list,n] performs n out shuffles on list. |
Perform an out shuffle on a list of 10 items:
In[1]:= |
Out[1]= |
Perform an out shuffle 3 times to a list:
In[2]:= |
Out[2]= |
Confirm that this is the same:
In[3]:= |
Out[3]= |
The list can contain expressions of different types:
In[4]:= |
Out[4]= |
Create a sorted deck of cards:
In[5]:= |
Out[5]= |
Shuffle the deck once:
In[6]:= |
Out[6]= |
The original is obtained after only 8 out shuffles:
In[7]:= |
Out[7]= |
An out shuffle does not change the first and last items for a list of even length:
In[8]:= |
Out[8]= |
An out shuffle does not change the first element:
In[9]:= |
Out[9]= |
For a list of two, nothing happens:
In[10]:= |
Out[10]= |
Figure out after how many out shuffles a list of size L returns to its original order:
In[11]:= |
For lists of even length, the number of shuffles to return to the original order is known analytically:
In[12]:= |
Out[12]= |
In[13]:= |
Out[13]= |
Visualize how the positions of items are changed for a list of length 22 in the form of a Graph:
In[14]:= |
Confirm that six nested out shuffles return the list of 22 items to the original order:
In[15]:= |
Zero iterations returns the original list:
In[16]:= |
Out[16]= |
Plot how many out shuffles are needed to return to the original order for a list of length L:
In[17]:= |
Out[19]= |
Wolfram Language 11.3 (March 2018) or above
This work is licensed under a Creative Commons Attribution 4.0 International License