Function Repository Resource:

ReverseAlternatingPermutationQ

Source Notebook

Determine whether a permutation is a reverse alternating permutation

Contributed by: Motoharu Ito

ResourceFunction["ReverseAlternatingPermutationQ"][perm]

returns True if perm is a reverse alternating permutation, and False otherwise.

Details

A permutation is reverse alternating if it starts with a descent and then ascents and descents alternate.

Examples

Basic Examples (1) 

Test whether {4,1,6,2,5,3} is reverse alternating:

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

Scope (1) 

The complement of an alternating permutation is a reverse alternating permutation:

In[2]:=
ResourceFunction["ReverseAlternatingPermutationQ"][
 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