A215577 Number of nonintersecting (or self-avoiding) rook paths joining opposite corner cells of an n X n X n grid, avoiding cells that are not on the surface.
1, 18, 340812, 1553113040
Offset: 1
Programs
-
C
#include
// GCC -O3 char grid[4][4][4]; long long SIZE; long long calc_ways(long long x, long long y, long long z) { long long n; if (grid[x][y][z]) return 0; if (x+y+z==SIZE*3-3) return 1; grid[x][y][z]=1; n=0; if (x>0) n =calc_ways(x-1,y,z); // go left if (x 0) n+=calc_ways(x,y-1,z); // down if (y 0) n+=calc_ways(x,y,z-1); // level down if (z
Comments