Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Get the next permutation in lexicographic order
ResourceFunction["NextPermutation"][p] gives the permutation following p in lexicographic order. |
Get the next permutation in lexicographic order:
In[1]:= | ![]() |
Out[1]= | ![]() |
The permutation that follows the highest-indexed one is the lowest-indexed one, wherein the elements are sorted:
In[2]:= | ![]() |
Out[2]= | ![]() |
This work is licensed under a Creative Commons Attribution 4.0 International License