Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Test whether the permutation list is completely scrambled
ResourceFunction["DerangementQ"][p] tests whether the permutation list p is such that no element appears in its original position. |
No elements are in their original places:
In[1]:= |
|
Out[1]= |
|
For even n, the list {n,…,3,2,1} is a derangement:
In[2]:= |
|
Out[2]= |
|
The chances are about 1 in 3 that a permutation is a derangement:
In[3]:= |
|
Out[3]= |
|
This work is licensed under a Creative Commons Attribution 4.0 International License