OFFSET
0,3
LINKS
Alois P. Heinz, Table of n, a(n) for n = 0..200
MAPLE
a:= n-> add(add(w(na, nb, n-na-nb, 0),
nb=ceil((n-na)/2)..min(n-na, na)), na=ceil(n/3)..n):
w:= proc(a, b, c, x) option remember;
`if`([a, b, c]=[0$3], 1, `if`(a>0 and x<2, w(a-1, b, c, 1), 0)+
`if`(b>0, w(a, b-1, c, `if`(x=1, 2, 0)), 0)+
`if`(c>0, w(a, b, c-1, 0), 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], {nb, Ceiling[(n - na)/2], Min[n - na, na]}], {na, Ceiling[n/3], n}];
w[a_, b_, c_, x_] := w[a, b, c, x] = If[{a, b, c} == {0, 0, 0}, 1, If[a > 0 && x < 2, w[a - 1, b, c, 1], 0] + If[b > 0, w[a, b - 1, c, If[x == 1, 2, 0]], 0] + If[c > 0, w[a, b, c - 1, 0], 0]];
a /@ Range[0, 40] (* Jean-François Alcover, Nov 11 2020, after Alois P. Heinz *)
PROG
(Sage)
def atleastcond(w):
return w.count(0) >= w.count(1) >= w.count(2)
def avoidsaba(w):
for i in range(len(w)-2):
if w[i] == 0 and w[i+1] == 1 and w[i+2] == 0:
return False
return True
len([w for w in Words([0, 1, 2], length=6) if atleastcond(w) and avoidsaba(w)])
# Jenny Li (jiemi2007(AT)yahoo.ca), Apr 17 2010
CROSSREFS
KEYWORD
nonn
AUTHOR
Jenny Li (jiemi2007(AT)yahoo.ca), Apr 15 2010, Apr 17 2010
EXTENSIONS
Extended beyond a(15) by Alois P. Heinz, May 22 2012
STATUS
approved