A328345 Number of n-step walks on cubic lattice starting at (0,0,0), ending at (floor(n/3), floor((n+1)/3), floor((n+2)/3)) and using steps (0,0,1), (0,1,0), (1,0,0), (-1,1,1), (1,-1,1), and (1,1,-1).
1, 1, 4, 21, 88, 440, 2385, 11781, 62832, 352128, 1842240, 10132320, 57775905, 311810785, 1746140396, 10060071021, 55367204256, 313747490784, 1820016119376, 10152658848528, 58015193420160, 338183208699840, 1905152077559808, 10954624445968896, 64089909936535329
Offset: 0
Examples
a(2) = 4: [(0,0,0),(1,0,0),(0,1,1)], [(0,0,0),(0,1,0),(0,1,1)], [(0,0,0),(0,0,1),(0,1,1)], [(0,0,0),(-1,1,1),(0,1,1)].
Links
- Alois P. Heinz, Table of n, a(n) for n = 0..650
- Wikipedia, Lattice path
- Wikipedia, Self-avoiding walk
Programs
-
Maple
b:= proc(l) option remember; `if`(l[-1]=0, 1, (r-> add(add( add(`if`(i+j+k=1, (h-> `if`(add(t, t=h)<0, 0, b(h)))( sort(l-[i, j, k])), 0), k=r), j=r), i=r))([$-1..1])) end: a:= n-> b([floor((n+i)/3)$i=0..2]): seq(a(n), n=0..24);
-
Mathematica
b[l_] := b[l] = If[Last[l] == 0, 1, Sum[If[i + j + k == 1, Function[h, If[Total[h] < 0, 0, b[h]]][Sort[l - {i, j, k}]], 0], {i, {-1, 0, 1}}, {j, {-1, 0, 1}}, {k, {-1, 0, 1}}]]; a[n_] := b[Table[Floor[(n + i)/3], {i, 0, 2}]]; a /@ Range[0, 24] (* Jean-François Alcover, May 12 2020, after Maple *)
Comments