OFFSET
0,7
COMMENTS
We define a sequence to be weakly alternating if it is alternately weakly increasing and weakly decreasing, starting with either. Then a sequence is (strongly) alternating iff it is a weakly alternating anti-run.
LINKS
Andrew Howroyd, Table of n, a(n) for n = 0..1000 (terms 0..55 from Martin Ehrenstein)
Wikipedia, Alternating permutation
EXAMPLE
The a(6) = 12 compositions:
(1,1,2,2,1) (1,1,2,3) (1,2,4)
(1,2,1,1,2) (1,2,3,1) (4,2,1)
(1,2,2,1,1) (1,3,2,1)
(2,1,1,2,1) (2,1,1,3)
(3,1,1,2)
(3,2,1,1)
MATHEMATICA
wwkQ[y_]:=And@@Table[If[EvenQ[m], y[[m]]<=y[[m+1]], y[[m]]>=y[[m+1]]], {m, 1, Length[y]-1}]||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], !wwkQ[#]&]], {n, 0, 10}]
CROSSREFS
The strong version is A345192.
The complement is counted by A349052.
The version for ordered factorizations is A350139.
A001700 counts compositions of 2n with alternating sum 0.
A003242 counts Carlitz (anti-run) compositions.
A106356 counts compositions by number of maximal anti-runs.
A344604 counts alternating compositions with twins.
A345164 counts alternating ordered prime factorizations.
A349054 counts strict alternating compositions.
KEYWORD
nonn
AUTHOR
Gus Wiseman, Dec 16 2021
EXTENSIONS
a(21)-a(35) from Martin Ehrenstein, Jan 08 2022
STATUS
approved