OFFSET
0,3
COMMENTS
We define a pattern to be a finite sequence covering an initial interval of positive integers. Patterns are counted by A000670 and ranked by A333217.
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). An alternating pattern is necessarily an anti-run (A005649).
The version with twins (A344605) is identical to this sequence except with a(2) = 3 instead of 2.
From Gus Wiseman, Jan 16 2022: (Start)
Conjecture: Also the number of weakly up/down patterns of length n, where a sequence is weakly up/down if it is alternately weakly increasing and weakly decreasing, starting with an increase. For example, the a(0) = 1 through a(3) = 6 weakly up/down patterns are:
() (1) (1,1) (1,1,1)
(2,1) (1,1,2)
(2,1,1)
(2,1,2)
(2,1,3)
(3,1,2)
(End)
LINKS
Andrew Howroyd, Table of n, a(n) for n = 0..200
FORMULA
a(n) = 2*A350354(n) for n >= 2. - Andrew Howroyd, Feb 04 2022
EXAMPLE
The a(0) = 1 through a(3) = 6 alternating patterns:
() (1) (1,2) (1,2,1)
(2,1) (1,3,2)
(2,1,2)
(2,1,3)
(2,3,1)
(3,1,2)
MATHEMATICA
wigQ[y_]:=Or[Length[y]==0, Length[Split[y]]== Length[y]&&Length[Split[Sign[Differences[y]]]]==Length[y]-1];
allnorm[n_]:=If[n<=0, {{}}, Function[s, Array[Count[s, y_/; y<=#]+1&, n]]/@Subsets[Range[n-1]+1]];
Table[Length[Select[Join@@Permutations/@allnorm[n], wigQ]], {n, 0, 6}]
PROG
(PARI)
F(p, x) = {sum(k=0, p, (-1)^((k+1)\2)*binomial((p+k)\2, k)*x^k)}
R(n, k) = {Vec(if(k==1, x, 2*F(k-2, -x)/F(k-1, x)-2-(k-2)*x) + O(x*x^n))}
seq(n)= {concat([1], sum(k=1, n, R(n, k)*sum(r=k, n, binomial(r, k)*(-1)^(r-k)) ))} \\ Andrew Howroyd, Feb 04 2022
CROSSREFS
KEYWORD
nonn
AUTHOR
Gus Wiseman, Jun 17 2021
EXTENSIONS
a(10)-a(18) from Alois P. Heinz, Dec 10 2021
Terms a(19) and beyond from Andrew Howroyd, Feb 04 2022
STATUS
approved