OFFSET
0,6
COMMENTS
A composition of n is a finite sequence of positive integers summing to n.
Also compositions contiguously matching the pattern (1,1,1).
FORMULA
EXAMPLE
The a(3) = 1 through a(7) = 18 compositions:
(111) (1111) (1112) (222) (1114)
(2111) (1113) (1222)
(11111) (3111) (2221)
(11112) (4111)
(11121) (11113)
(12111) (11122)
(21111) (11131)
(111111) (13111)
(21112)
(22111)
(31111)
(111112)
(111121)
(111211)
(112111)
(121111)
(211111)
(1111111)
MAPLE
b:= proc(n, t) option remember; `if`(n=0, 1, add(`if`(abs(t)<>j,
b(n-j, j), `if`(t=-j, 0, b(n-j, -j))), j=1..n))
end:
a:= n-> ceil(2^(n-1))-b(n, 0):
seq(a(n), n=0..40); # Alois P. Heinz, Jul 06 2020
MATHEMATICA
Table[Length[Select[Join@@Permutations/@IntegerPartitions[n], MatchQ[#, {___, x_, x_, x_, ___}]&]], {n, 0, 10}]
(* Second program: *)
b[n_, t_] := b[n, t] = If[n == 0, 1, Sum[If[Abs[t] != j,
b[n - j, j], If[t == -j, 0, b[n - j, -j]]], {j, 1, n}]];
a[n_] := Ceiling[2^(n-1)] - b[n, 0];
a /@ Range[0, 40] (* Jean-François Alcover, May 21 2021, after Alois P. Heinz *)
CROSSREFS
Compositions contiguously avoiding (1,1) are A003242.
Compositions with some part > 2 are A008466.
Compositions by number of adjacent equal parts are A106356.
Compositions where each part is adjacent to an equal part are A114901.
Compositions contiguously avoiding (1,1,1) are A128695.
Compositions with adjacent parts coprime are A167606.
Compositions contiguously matching (1,1) are A261983.
Compositions with all equal parts contiguous are A274174.
Patterns contiguously matched by compositions are A335457.
KEYWORD
nonn
AUTHOR
Gus Wiseman, Jul 06 2020
EXTENSIONS
a(23)-a(35) from Alois P. Heinz, Jul 06 2020
STATUS
approved