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!)
A176433 The number of words of length n created with letters a, b, and 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 and no subwords (any adjacent or nonadjacent subsequence of letters) of the form abc. 1
1, 1, 3, 8, 15, 35, 96, 186, 419, 1035, 2021, 4353, 10171, 19721, 41466, 93118, 180018, 371539, 813425, 1566398, 3194133, 6859558, 13179004, 26617619, 56371355, 108060479, 216736146, 453947049, 868857655, 1732792511, 3598157885, 6877348410, 13655273038 (list; graph; refs; listen; history; text; internal format)
OFFSET
0,3
LINKS
MAPLE
a:= n-> add(add(w(na, nb, n-na-nb, 0, 0),
nb=ceil((n-na)/2)..min(n-na, na)), na=ceil(n/3)..n):
w:= proc(a, b, c, x, y) option remember;
`if`([a, b, c]=[0$3], 1,
`if`(a>0 and x<2 and y<2, w(a-1, b, c, 1, y), 0)+
`if`(b>0, w(a, b-1, c, `if`(x=1, 2, 0), `if`(y>0, 2, 0)), 0)+
`if`(c>0, w(a, b, c-1, 0, `if`(y=0, 1, y)), 0))
end:
seq(a(n), n=0..40); # Alois P. Heinz, May 22 2012
MATHEMATICA
a[n_] := Sum[Sum[w[na, nb, n - na - nb, 0, 0], {nb, Ceiling[(n - na)/2], Min[n - na, na]}], {na, Ceiling[n/3], n}];
w[a_, b_, c_, x_, y_] := w[a, b, c, x, y] =
If[{a, b, c} == {0, 0, 0}, 1,
If[a > 0 && x < 2 && y < 2, w[a - 1, b, c, 1, y], 0] +
If[b > 0, w[a, b - 1, c, If[x == 1, 2, 0], If[y > 0, 2, 0]], 0] +
If[c > 0, w[a, b, c - 1, 0, If[y == 0, 1, y]], 0]];
a /@ Range[0, 40] (* Jean-François Alcover, Nov 20 2020, after Alois P. Heinz *)
PROG
(C#) private static void GenerateCombo(string currentWord, int maxLength, ICollection<string> currentStrings) { if (currentWord.Length < maxLength) { GenerateCombo(currentWord+"a", maxLength, currentStrings); GenerateCombo(currentWord+"b", maxLength, currentStrings); GenerateCombo(currentWord+"c", maxLength, currentStrings); } else { if (Regex.IsMatch(currentWord, "aba")) return; if (Regex.IsMatch(currentWord, "[abc]*a[abc]*b[abc]*c[abc]*")) return; int aCount = CountOccurrences('a', currentWord); int bCount = CountOccurrences('b', currentWord); int cCount = CountOccurrences('c', currentWord); if(cCount > bCount) return; if(bCount > aCount) return; currentStrings.Add(currentWord); } } private static int CountOccurrences(char ch, string word) { int rez = 0; for(int i = 0 ; i < word.Length; i ++) if (word == ch) rez++; return rez; }
CROSSREFS
Sequence in context: A032234 A032255 A137475 * A132810 A032159 A174982
KEYWORD
nonn
AUTHOR
Patrick McQuade (patrick.mcquade(AT)peelsb.com), Apr 17 2010
EXTENSIONS
More terms from Alois P. Heinz, May 22 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 | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified September 15 12:32 EDT 2024. Contains 375938 sequences. (Running on oeis4.)