Function Repository Resource:

ComplementPermutation

Source Notebook

Get the complement of a permutation

Contributed by: Motoharu Ito

ResourceFunction["ComplementPermutation"][perm]

returns the complement of the permutation perm.

Details

The complement permutation c(p) of the permutation p=p1p2…pn is the permutation p1'p2'…pn' where pk'=n+1-pk.

Examples

Basic Examples (1) 

Find the complement of a permutation:

In[1]:=
ResourceFunction["ComplementPermutation"][{4, 1, 6, 2, 5, 3}]
Out[1]=

Scope (1) 

The complement of an alternating permutation is a reverse alternating permutation (a descent followed by alternating ascents and descents):

In[2]:=
ResourceFunction["ComplementPermutation"][{4, 7, 2, 3, 1, 6, 5}]
Out[2]=

Publisher

Motoharu Ito

Version History

  • 1.0.0 – 28 November 2022

Source Metadata

Related Resources

License Information