OFFSET
0,2
LINKS
Alois P. Heinz, Table of n, a(n) for n = 0..700
Mireille Bousquet-Mélou, Families of prudent self-avoiding walks, DMTCS proc. AJ, 2008, 167-180.
Mireille Bousquet-Mélou, Families of prudent self-avoiding walks, arXiv:0804.4843 [math.CO], 2008-2009.
Enrica Duchi, On some classes of prudent walks, in: FPSAC'05, Taormina, Italy, 2005.
EXAMPLE
a(4) = 20: ENNW, ENWN, ENWW, NENW, NNNN, NNNW, NNWN, NNWW, NWNN, NWNW, NWWN, NWWW, WNNN, WNNW, WNWN, WNWW, WWNN, WWNW, WWWN, WWWW.
MAPLE
b:= proc(d, i, n, x, y, w) option remember;
`if`(y+w>n, 0, `if`(n=0, `if`(y=0 and w=0, 1, 0),
`if`(d<>3, b(1, evalb(x=0), n-1, max(x-1, 0), y, w+1), 0) +
`if`(d<>4, b(2, evalb(y=0), n-1, x, max(y-1, 0), w), 0) +
`if`(d in [0, 3] or d=2 and i, b(3, false, n-1, x+1, y,
max(w-1, 0)), 0) +
`if`(d in [0, 4] or d=1 and i, b(4, false, n-1, x, y+1, w), 0)))
end:
a:= n-> b(0, false, n, 0, 0, 0):
seq(a(n), n=0..30);
MATHEMATICA
b[d_, i_, n_, x_, y_, w_] := b[d, i, n, x, y, w] = If[y + w > n, 0,
If[n==0, If[y==0 && w==0, 1, 0],
If[d != 3, b[1, x==0, n-1, Max[x-1, 0], y, w+1], 0] +
If[d != 4, b[2, y==0, n-1, x, Max[y-1, 0], w], 0] +
If[d==0 || d==3 || d==2 && i, b[3, False, n-1, x+1, y, Max[w-1, 0]], 0] +
If[d==0 || d==4 || d==1 && i, b[4, False, n-1, x, y+1, w], 0]]
];
a[n_] := b[0, False, n, 0, 0, 0];
a /@ Range[0, 31] (* Jean-François Alcover, Sep 22 2019, after Alois P. Heinz *)
CROSSREFS
KEYWORD
nonn,walk
AUTHOR
Alois P. Heinz, Jun 10 2011
STATUS
approved