Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Give the indices of a permutation where there is an immediate ascent
ResourceFunction["PermutationAscents"][p] gives the indices i where pi<pi+1, where the permutation p={p1,p2,…,pn} is written as a list. |
Consider the permutation:
| In[1]:= |
Its ascents are at the indices 1, 3, 5, 8, corresponding to 2 < 8, 1 < 5, 4 < 7, 3 < 9:
| In[2]:= |
| Out[2]= |
The descents follow easily:
| In[3]:= |
| Out[3]= |
A permutation in cycle form:
| In[4]:= |
This does not work:
| In[5]:= |
| Out[5]= |
Convert from cycle to list form:
| In[6]:= |
| Out[6]= |
Now this finds the ascents:
| In[7]:= |
| Out[7]= |
Wolfram Language 11.3 (March 2018) or above
This work is licensed under a Creative Commons Attribution 4.0 International License