OFFSET
0,2
COMMENTS
Lattice points may have negative coordinates, and different walks may differ in length. All walks are self-avoiding.
LINKS
Alois P. Heinz, Table of n, a(n) for n = 0..1000
Alois P. Heinz, Animation of a(5) = 298 walks
Wikipedia, Counting lattice paths
Wikipedia, Self-avoiding walk
MAPLE
s:= proc(n) option remember;
`if`(n=0, [[]], map(x-> seq([x[], i], i=-1..1), s(n-1)))
end:
b:= proc(l, v) option remember; (n-> `if`(l=[0$n], 1, add((h-> `if`(
add(i^2, i=h)<add(i^2, i=l) and add(i^2, i=v-h)>add(i^2, i=v-l)
, b(h, v), 0))(l+x), x=s(n))))(nops(l))
end:
a:= n-> b([n, 1]$2):
seq(a(n), n=0..30);
MATHEMATICA
s[n_] := s[n] = If[n == 0, {{}}, Sequence @@
Table[Append[#, i], {i, -1, 1}]& /@ s[n-1]];
b[l_, v_] := b[l, v] = With[{n = Length[l]},
If[l == Table[0, {n}], 1, Sum[With[{h = l + x},
If[h.h<l.l && (v-h).(v-h)>(v-l).(v-l), b[h, v], 0]], {x, s[n]}]]];
a[n_] := b[{n, 1}, {n, 1}];
Table[a[n], {n, 0, 30}] (* Jean-François Alcover, Nov 04 2021, after Alois P. Heinz *)
CROSSREFS
KEYWORD
nonn,walk
AUTHOR
Alois P. Heinz, Sep 20 2021
STATUS
approved