OFFSET
0,3
LINKS
Alois P. Heinz, Table of n, a(n) for n = 0..1470
Alois P. Heinz, Animation of a(6)=186 walks
Wikipedia, Lattice path
Wikipedia, Self-avoiding walk
MAPLE
b:= proc(x, y) option remember; `if`(x<0 or y<0, 0,
`if`(x=0 and y=0, 1, `if`(x>y-2, b(x, y-1), 0)+
`if`(x<y+2, b(x-1, y), 0)+`if`(x>y, b(x-1, y-1), 0)+
`if`(x<y-1, b(x+1, y-1), 0)+`if`(x>y+1, b(x-1, y+1), 0)))
end:
a:= n-> b(n, 0):
seq(a(n), n=0..30);
MATHEMATICA
b[x_, y_] := b[x, y] = If[x < 0 || y < 0, 0,
If[x == 0 && y == 0, 1, If[x > y - 2, b[x, y - 1], 0] +
If[x < y + 2, b[x - 1, y], 0] + If[x > y, b[x - 1, y - 1], 0] +
If[x < y - 1, b[x + 1, y - 1], 0] + If[x > y + 1, b[x - 1, y + 1], 0]]];
a[n_] := b[n, 0];
Table[a[n], {n, 0, 30}] (* Jean-François Alcover, Jun 02 2018, from Maple *)
CROSSREFS
KEYWORD
nonn,walk
AUTHOR
Alois P. Heinz, Apr 24 2018
STATUS
approved