login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A174982 The number of words of length n with 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 aba or abc. 2

%I #11 Nov 11 2020 08:25:01

%S 1,1,3,8,15,38,120,258,683,2116,4796,12800,39094,91412,245478,742376,

%T 1772851,4779936,14342766,34772193,94010374,280321572,687416534,

%U 1862299561,5524586198,13670204608,37092812772,109567253600,273104180926,741976123650,2183764222716

%N The number of words of length n with 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 aba or abc.

%H Alois P. Heinz, <a href="/A174982/b174982.txt">Table of n, a(n) for n = 0..200</a>

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

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

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

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

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

%p +w(a, b-1, c, 2) +w(a, b, c-1, 0) +w(a, b, c-1, 1),

%p `if`(t=1, w(a-1, b, c, 0) +w(a-1, b, c, 1), w(a, b-1, c, 1)))))

%p end:

%p seq (a(n), n=0..40); # _Alois P. Heinz_, May 07 2012

%t 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}];

%t 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, b - 1, c, 0] + w[a, b - 1, c, 2] + w[a, b, c - 1, 0] + w[a, b, c - 1, 1], If[t == 1, w[a - 1, b, c, 0] + w[a - 1, b, c, 1], w[a, b - 1, c, 1]]]]];

%t a /@ Range[0, 40] (* _Jean-François Alcover_, Nov 11 2020, after _Alois P. Heinz_ *)

%K nonn

%O 0,3

%A Kusum (k1malik(AT)yahoo.ca), Apr 03 2010

%E a(0) inserted and extended beyond a(15) by _Alois P. Heinz_, May 07 2012

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

License Agreements, Terms of Use, Privacy Policy. .

Last modified July 16 17:03 EDT 2024. Contains 374358 sequences. (Running on oeis4.)