OFFSET
0,5
COMMENTS
First differs from A348382 at a(6) = 19, A348382(6) = 17. The two non-alternating non-twin compositions of 6 that are not an anti-run are (1,2,3) and (3,2,1).
A sequence is alternating if it is alternately strictly increasing and strictly decreasing, starting with either. For example, the partition (3,2,2,2,1) has no alternating permutations, even though it does have the anti-run permutations (2,3,2,1,2) and (2,1,2,3,2). Alternating permutations of multisets are a generalization of alternating or up-down permutations of {1..n}.
LINKS
Andrew Howroyd, Table of n, a(n) for n = 0..1000
Wikipedia, Alternating permutation
EXAMPLE
The a(3) = 1 through a(6) = 19 compositions:
(1,1,1) (1,1,2) (1,1,3) (1,1,4)
(2,1,1) (1,2,2) (1,2,3)
(1,1,1,1) (2,2,1) (2,2,2)
(3,1,1) (3,2,1)
(1,1,1,2) (4,1,1)
(1,1,2,1) (1,1,1,3)
(1,2,1,1) (1,1,2,2)
(2,1,1,1) (1,1,3,1)
(1,1,1,1,1) (1,2,2,1)
(1,3,1,1)
(2,1,1,2)
(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
Table[Length[Select[Join@@Permutations/@IntegerPartitions[n], MatchQ[#, {___, x_, y_, z_, ___}/; x<=y<=z||x>=y>=z]&]], {n, 0, 15}]
CROSSREFS
Non-twin compositions are counted by A051049.
The complement is counted by A344604.
An unordered version is A344654.
The non-anti-run case is A348382.
A001250 counts alternating permutations.
A106356 counts compositions by number of maximal anti-runs.
A114901 counts compositions where each part is adjacent to an equal part.
A344614 counts compositions avoiding (1,2,3) and (3,2,1) adjacent.
KEYWORD
nonn
AUTHOR
Gus Wiseman, Oct 26 2021
EXTENSIONS
a(26) onwards from Andrew Howroyd, Jan 31 2024
STATUS
approved