OFFSET
0,3
COMMENTS
We define a composition to be alternating including twins (x,x) if there are no adjacent triples (..., x, y, z, ...) where x <= y <= z or x >= y >= z. Except in the case of twins (x,x), all such compositions are anti-runs (A003242). These compositions avoid the weak consecutive patterns (1,2,3) and (3,2,1), the strict version being A344614.
The version without twins (x,x) is A025047 (alternating compositions).
LINKS
Andrew Howroyd, Table of n, a(n) for n = 0..1000
FORMULA
EXAMPLE
The a(1) = 1 through a(7) = 19 compositions:
(1) (2) (3) (4) (5) (6) (7)
(11) (12) (13) (14) (15) (16)
(21) (22) (23) (24) (25)
(31) (32) (33) (34)
(121) (41) (42) (43)
(131) (51) (52)
(212) (132) (61)
(141) (142)
(213) (151)
(231) (214)
(312) (232)
(1212) (241)
(2121) (313)
(412)
(1213)
(1312)
(2131)
(3121)
(12121)
MATHEMATICA
Table[Length[Select[Join@@Permutations/@IntegerPartitions[n], !MatchQ[#, {___, x_, y_, z_, ___}/; x<=y<=z||x>=y>=z]&]], {n, 0, 15}]
CROSSREFS
A001250 counts alternating permutations.
A005649 counts anti-run patterns.
A106356 counts compositions by number of maximal anti-runs.
A114901 counts compositions where each part is adjacent to an equal part.
A325534 counts separable partitions.
A325535 counts inseparable partitions.
A344605 counts alternating patterns including twins.
A344606 counts alternating permutations of prime factors including twins.
Counting compositions by patterns:
- A011782 no conditions.
- A003242 avoiding (1,1) adjacent.
- A102726 avoiding (1,2,3).
- A106351 avoiding (1,1) adjacent by sum and length.
- A128695 avoiding (1,1,1) adjacent.
- A128761 avoiding (1,2,3) adjacent.
- A232432 avoiding (1,1,1).
- A335456 all patterns.
- A335457 all patterns adjacent.
- A335514 matching (1,2,3).
- A344614 avoiding (1,2,3) and (3,2,1) adjacent.
- A344615 weakly avoiding (1,2,3) adjacent.
KEYWORD
nonn
AUTHOR
Gus Wiseman, May 27 2021
EXTENSIONS
a(21)-a(40) from Alois P. Heinz, Nov 04 2021
STATUS
approved