Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Check if a list is the inversion vector of a permutation written as a list
ResourceFunction["InversionVectorQ"][iv] checks if iv is the inversion vector of a permutation list. |
This permutation has three numbers greater than 1 before 1, two numbers greater than 2 before 2 and so on:
In[1]:= |
Therefore this is its inversion vector:
In[2]:= |
Here is a check:
In[3]:= |
Out[3]= |
The positive integer 23 gives {3,2,1,0} in the factorial base, so {3,2,1,0} is an inversion vector:
In[4]:= |
Out[4]= |
Every inversion vector must end in 0 because the largest entry in a permutation list has nothing but smaller entries before it:
In[5]:= |
Out[5]= |
This work is licensed under a Creative Commons Attribution 4.0 International License