OFFSET
1,1
COMMENTS
We define a sequence to be weakly alternating if it is alternately weakly increasing and weakly decreasing, starting with either.
The k-th composition in standard order (graded reverse-lexicographic, A066099) is obtained by taking the set of positions of 1's in the reversed binary expansion of k, prepending 0, taking first differences, and reversing again. This gives a bijective correspondence between nonnegative integers and integer compositions.
This sequence ranks compositions that are weakly but not strongly alternating.
LINKS
EXAMPLE
The terms and corresponding compositions begin:
3: (1,1)
7: (1,1,1)
10: (2,2)
11: (2,1,1)
14: (1,1,2)
15: (1,1,1,1)
19: (3,1,1)
21: (2,2,1)
23: (2,1,1,1)
26: (1,2,2)
27: (1,2,1,1)
28: (1,1,3)
29: (1,1,2,1)
30: (1,1,1,2)
31: (1,1,1,1,1)
MATHEMATICA
stc[n_]:=Differences[Prepend[Join@@Position[ Reverse[IntegerDigits[n, 2]], 1], 0]]//Reverse;
whkQ[y_]:=And@@Table[If[EvenQ[m], y[[m]]<=y[[m+1]], y[[m]]>=y[[m+1]]], {m, 1, Length[y]-1}];
Select[Range[0, 100], (whkQ[stc[#]]||whkQ[-stc[#]])&&MatchQ[stc[#], {___, x_, x_, ___}]&]
CROSSREFS
KEYWORD
nonn
AUTHOR
Gus Wiseman, Dec 15 2021
STATUS
approved