OFFSET
0,3
COMMENTS
We define a sequence to be weakly alternating if it is alternately weakly increasing and weakly decreasing, starting with either. A sequence is 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)
EXAMPLE
The a(5) = 16 compositions:
(1,1,1,1,1) (1,1,1,2) (1,1,3) (1,4) (5)
(1,1,2,1) (1,2,2) (2,3)
(1,2,1,1) (1,3,1) (3,2)
(2,1,1,1) (2,1,2) (4,1)
(2,2,1)
(3,1,1)
The a(6) = 28 compositions:
(111111) (11112) (1113) (114) (15) (6)
(11121) (1122) (132) (24)
(11211) (1131) (141) (33)
(12111) (1212) (213) (42)
(21111) (1311) (222) (51)
(2121) (231)
(2211) (312)
(3111) (411)
MATHEMATICA
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[-#]&]], {n, 0, 10}]
PROG
(PARI)
C(n, f)={my(M=matrix(n, n, j, k, k>=j), s=M[, n]); for(b=1, n, f=!f; M=matrix(n, n, j, k, if(k<j, if(f, M[j-k, k], M[j-k, n]-if(k>1, M[j-k, k-1]) ))); for(k=2, n, M[, k]+=M[, k-1]); s+=M[, n]); s~}
seq(n) = concat([1], C(n, 0) + C(n, 1) - vector(n, j, numdiv(j))) \\ Andrew Howroyd, Jan 31 2024
CROSSREFS
A001700 counts compositions of 2n with alternating sum 0.
A003242 counts Carlitz (anti-run) compositions.
A011782 counts compositions.
A106356 counts compositions by number of maximal anti-runs.
A344604 counts alternating compositions with twins.
A349054 counts strict alternating compositions.
KEYWORD
nonn
AUTHOR
Gus Wiseman, Nov 29 2021
EXTENSIONS
a(21)-a(37) from Martin Ehrenstein, Jan 08 2022
STATUS
approved