login
The OEIS Foundation is supported by donations from users of the OEIS and by a grant from the Simons Foundation.

 

Logo

Please make a donation to keep the OEIS running. We are now in our 56th year. In the past year we added 10000 new sequences and reached almost 9000 citations (which often say "discovered thanks to the OEIS").
Other ways to donate

Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A204340 The number of words of length n created with the letters a,b,c with at least as many a's as b's and at least as many b's as c's and no adjacent letters forming the pattern bba. 1
1, 1, 3, 10, 21, 57, 182, 426, 1167, 3679, 8991, 24873, 77492, 194449, 541194, 1670783, 4267991, 11926782, 36559601, 94604822, 265135713, 808106960, 2111760491, 5931204471, 17993213402, 47385794268, 133315710843, 402849979395, 1067608305030, 3007697623335 (list; graph; refs; listen; history; text; internal format)
OFFSET

0,3

LINKS

Alois P. Heinz, Table of n, a(n) for n = 0..200

EXAMPLE

For n=1 the a(1)=1 solution is: a

For n=2 the a(2)=3 solutions are: aa,ab,ba

For n=3 the a(3)=10 solutions are: aaa,aab,aba,abc,acb,baa,bac,bca,cab,cba

MAPLE

makebbaavoiders := proc (n) local out, tout, i;

   if n = 0 then return [[]] end if;

   tout := makebbaavoiders(n-1);

   out := [];

   for i to nops(tout) do

   if 2 <= nops(tout[i]) and tout[i][-1] = 1 and tout[i][-2] = 1 then

       out := [op(out), [op(tout[i]), 1], [op(tout[i]), 2]]

   else

       out := [op(out), [op(tout[i]), 0], [op(tout[i]), 1], [op(tout[i]), 2]]

   end if end do;

   return out;

end proc;

count := proc (lst, val)

    return nops(select(proc (x) options operator, arrow; x = val end proc, lst))

end proc;

nops(select(proc (w) options operator, arrow; count(w, 2) <= count(w, 1) end proc, select(proc (w) options operator, arrow; count(w, 1) <=count(w, 0) end proc, makebbaavoiders(7))));

# second Maple program:

a:= n-> add(add(add(w(na, nb, n-na-nb, t), t=0..2),

             nb=ceil((n-na)/2)..na), na=ceil(n/3)..n):

w:= proc(a, b, c, t) option remember;

      `if`(a=0 and b=0 and c=0, `if`(t=0, 1, 0),

      `if`(a<0 or b<0 or c<0, 0, `if`(t=0, w(a-1, b, c, 0)+

       w(a-1, b, c, 1) +w(a, b, c-1, 0) +w(a, b, c-1, 1)+

       w(a, b, c-1, 2), `if`(t=1, w(a, b-1, c, 0),

       w(a, b-1, c, 1) +w(a, b-1, c, 2)))))

    end:

seq(a(n), n=0..40);  # Alois P. Heinz, May 07 2012

MATHEMATICA

a[n_] := Sum[Sum[Sum[w[na, nb, n-na-nb, t], {t, 0, 2}], {nb, Ceiling[(n-na)/2], na}], {na, Ceiling[n/3], n}];

w[a_, b_, c_, t_] := w[a, b, c, t] =

  If[a == 0 && b == 0 && c == 0, If[t == 0, 1, 0],

  If[a < 0 || b < 0 || c < 0, 0, If[t == 0, w[a - 1, b, c, 0] +

  w[a - 1, b, c, 1] + w[a, b, c - 1, 0] + w[a, b, c - 1, 1] +

  w[a, b, c - 1, 2], If[t == 1, w[a, b - 1, c, 0],

  w[a, b - 1, c, 1] + w[a, b - 1, c, 2]]]]];

a /@ Range[0, 40] (* Jean-Fran├žois Alcover, Nov 20 2020, after Alois P. Heinz *)

CROSSREFS

Cf. A174982.

Sequence in context: A008837 A176098 A081950 * A331017 A207646 A071563

Adjacent sequences:  A204337 A204338 A204339 * A204341 A204342 A204343

KEYWORD

nonn,changed

AUTHOR

Jeff McManus, Jan 14 2012

EXTENSIONS

a(1)-a(13) confirmed and a(14) added by John W. Layman, Jan 18 2012

a(0) inserted and extended beyond a(14) by Alois P. Heinz, May 07 2012

STATUS

approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recent
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified November 28 06:36 EST 2020. Contains 338699 sequences. (Running on oeis4.)