OFFSET
0,5
COMMENTS
We define a sequence to be weakly alternating if it is alternately weakly increasing and weakly decreasing, starting with either.
This sequence counts compositions that are weakly but not strongly alternating; also weakly alternating non-anti-run compositions.
LINKS
Andrew Howroyd, Table of n, a(n) for n = 0..1000
Wikipedia, Alternating permutation
FORMULA
EXAMPLE
The a(2) = 1 through a(6) = 16 compositions:
(1,1) (1,1,1) (2,2) (1,1,3) (3,3)
(1,1,2) (1,2,2) (1,1,4)
(2,1,1) (2,2,1) (2,2,2)
(1,1,1,1) (3,1,1) (4,1,1)
(1,1,1,2) (1,1,1,3)
(1,1,2,1) (1,1,2,2)
(1,2,1,1) (1,1,3,1)
(2,1,1,1) (1,3,1,1)
(1,1,1,1,1) (2,2,1,1)
(3,1,1,1)
(1,1,1,1,2)
(1,1,1,2,1)
(1,1,2,1,1)
(1,2,1,1,1)
(2,1,1,1,1)
(1,1,1,1,1,1)
MATHEMATICA
wigQ[y_]:=Or[Length[y]==0, Length[Split[y]]==Length[y] &&Length[Split[Sign[Differences[y]]]]==Length[y]-1];
whkQ[y_]:=And@@Table[If[EvenQ[m], y[[m]]<=y[[m+1]], y[[m]]>=y[[m+1]]], {m, 1, Length[y]-1}];
Table[Length[Select[Join@@Permutations/@IntegerPartitions[n], (whkQ[#]||whkQ[-#])&&!wigQ[#]&]], {n, 0, 10}]
CROSSREFS
The version counting permutations of prime indices is A349798.
These compositions are ranked by A349799.
A348377 = non-alternating non-twin compositions.
Weakly alternating:
- A349057 = complement of standard composition numbers (too dense).
KEYWORD
nonn
AUTHOR
Gus Wiseman, Dec 16 2021
EXTENSIONS
a(21) onwards from Andrew Howroyd, Jan 31 2024
STATUS
approved