OFFSET
1,2
COMMENTS
We define the half-alternating sum of a sequence (A, B, C, D, E, F, G, ...) to be A + B - C - D + E + F - G - ..., and the skew-alternating sum to be A - B - C + D + E - F - G + ...
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.
MATHEMATICA
stc[n_]:=Differences[Prepend[Join@@Position[Reverse[IntegerDigits[n, 2]], 1], 0]]//Reverse;
halfats[f_]:=Sum[f[[i]]*(-1)^(1+Ceiling[i/2]), {i, Length[f]}];
skats[f_]:=Sum[f[[i]]*(-1)^(1+Ceiling[(i+1)/2]), {i, Length[f]}];
Select[Range[0, 1000], halfats[stc[#]]==0&&skats[stc[#]]==0&]
CROSSREFS
These compositions are counted by A228248.
KEYWORD
nonn
AUTHOR
Gus Wiseman, Oct 13 2022
STATUS
approved