A007764
Number of nonintersecting (or self-avoiding) rook paths joining opposite corners of an n X n grid.
Original entry on oeis.org
1, 2, 12, 184, 8512, 1262816, 575780564, 789360053252, 3266598486981642, 41044208702632496804, 1568758030464750013214100, 182413291514248049241470885236, 64528039343270018963357185158482118, 69450664761521361664274701548907358996488
Offset: 1
Suppose we start at (1,1) and end at (n,n). Let U, D, L, R denote steps that are up, down, left, right.
a(2) = 2: UR or RU.
a(3) = 12: UURR, UURDRU, UURDDRUU, URUR, URRU, URDRUU and their reflections in the x=y line.
- Steven R. Finch, Mathematical Constants, Cambridge, 2003, section 5.10, pp. 331-338.
- Guttmann A J and Jensen I 2022 Self-avoiding walks and polygons crossing a domain on the square and hexagonal lattices Journal of Physics A: Mathematical and Theoretical 55 012345, (33pp) ; arXiv:2208.06744, Aug 2022.
- D. E. Knuth, 'Things A Computer Scientist Rarely Talks About,' CSLI Publications, Stanford, CA, 2001, pages 27-28.
- D. E. Knuth, The Art of Computer Programming, Section 7.1.4.
- Shin-ichi Minato, The power of enumeration - BDD/ZDD-based algorithms for tackling combinatorial explosion, Chapter 3 of Applications of Zero-Suppressed Decision Diagrams, ed. T. Satsoa and J. T. Butler, Morgan & Claypool Publishers, 2014
- Shin-ichi Minato, Counting by ZDD, Encyclopedia of Algorithms, 2014, pp. 1-6.
- Netnews group rec.puzzles, Frequently Asked Questions (FAQ) file. (Science Section).
- I. Jensen, H. Iwashita, and R. Spaans, Table of n, a(n) for n = 1..27 (I. Jensen computed terms 1 to 20, H. Iwashita computed 21 and 22, R. Spaans computed 23 to 25, and H. Iwashita computed 26 and 27)
- M. Bousquet-Mélou, A. J. Guttmann and I. Jensen, Self-avoiding walks crossing a square, arXiv:cond-mat/0506341 [cond-mat.stat-mech], 2005.
- Doi, Maeda, Nagatomo, Niiyama, Sanson, Suzuki, et al., Time with class! Let's count! [Youtube-animation demonstrating this sequence. In Japanese with English translation]
- Steven R. Finch, Self-Avoiding-Walk Connective Constants
- Anthony J. Guttmann and Iwan Jensen, The gerrymander sequence, or A348456, arXiv:2211.14482 [math.CO], 2022.
- H. Iwashita, J. Kawahara, and S. Minato, ZDD-Based Computation of the Number of Paths in a Graph, TCS Technical Report, TCS-TR-A-12-60, Hokkaido University, September 18, 2012.
- H. Iwashita, Y. Nakazawa, J. Kawahara, T. Uno, and S. Minato, Efficient Computation of the Number of Paths in a Grid Graph with Minimal Perfect Hash Functions, TCS Technical Report, TCS-TR-A-13-64, Hokkaido University, April 26, 2013.
- I. Jensen, Series Expansions for Self-Avoiding Walks
- Shin-ichi Minato, Power of Enumeration - Recent Topics on BDD/ZDD-Based Techniques for Discrete Structure Manipulation, IEICE Transactions on Information and Systems, Volume E100.D (2017), Issue 8, p. 1556-1562.
- Shin-ichi Minato, Motivating Problems and Algorithmic Solutions, Algorithmic Foundations for Social Advancement, Springer, Singapore (2025), 17-29.
- OEIS Wiki, Self-avoiding_walks
- Kohei Shinohara, Atsuto Seko, Takashi Horiyama, Masakazu Ishihata, Junya Honda, and Isao Tanaka, Derivative structure enumeration using binary decision diagram, arXiv:2002.12603 [physics.comp-ph], 2020.
- Ruben Grønning Spaans, C program
- Jens Weise, Evolutionary Many-Objective Optimisation for Pathfinding Problems, Ph. D. Dissertation, Otto von Guercke Univ., Magdeburg (Germany, 2022), see p. 53.
- Eric Weisstein's World of Mathematics, Self-Avoiding Walk
-
# Using graphillion
from graphillion import GraphSet
import graphillion.tutorial as tl
def A007764(n):
if n == 1: return 1
universe = tl.grid(n - 1, n - 1)
GraphSet.set_universe(universe)
start, goal = 1, n * n
paths = GraphSet.paths(start, goal)
return paths.len()
print([A007764(n) for n in range(1, 10)]) # Seiichi Manyama, Mar 21 2020
Computed to n=12 by John Van Rosendale in 1981
Extended to n=22 using ZDD technique based on Knuth's The Art of Computer Programming (exercise 225 in 7.1.4) by H. Iwashita, J. Kawahara, and S. Minato, Sep 18 2012
Extended to n=25 using state space compression (with rank/unrank) and dynamic programming (based in I. Jensen) by
Ruben Grønning Spaans, Feb 22 2013
A120443
Number of (undirected) Hamiltonian paths in the n X n grid graph.
Original entry on oeis.org
1, 4, 20, 276, 4324, 229348, 13535280, 3023313284, 745416341496, 730044829512632, 786671485270308848, 3452664855804347354220, 16652005717670534681315580, 331809088406733654427925292528, 7263611367960266490262600117251524
Offset: 1
From _Robert FERREOL_, Apr 03 2019: (Start)
a(3) = 20:
there are 4 paths similar to
+ - + - +
|
+ - + - +
|
+ - + - +
8 paths similar to
+ - + - +
| |
+ + - +
| |
+ + - +
and 8 paths similar to
+ - + - +
| |
+ + +
| | |
+ + - +
(End)
- Jesper L. Jacobsen, Table of n, a(n) for n = 1..17
- J. L. Jacobsen, Exact enumeration of Hamiltonian circuits, walks and chains in two and three dimensions, J. Phys. A: Math. Theor. 40 (2007) 14667-14678.
- J.-M. Mayer, C. Guez and J. Dayantis, Exact computer enumeration of the number of Hamiltonian paths in small square plane lattices, Physical Review B, Vol. 42 Number 1, 1990.
- Eric Weisstein's World of Mathematics, Grid Graph
- Eric Weisstein's World of Mathematics, Hamiltonian Path
- Index entries for sequences related to graphs, Hamiltonian
More terms from Jesper L. Jacobsen (jesper.jacobsen(AT)u-psud.fr), Dec 12 2007
A000532
Number of Hamiltonian paths from NW to SW corners in an n X n grid.
Original entry on oeis.org
1, 1, 2, 8, 86, 1770, 88418, 8934966, 2087813834, 1013346943033, 1111598871478668, 2568944901392936854, 13251059359839620127088, 145194816279817259193401518, 3524171261632305641165676374930, 182653259988707123426135593460533473
Offset: 1
- Oliver R. Bellwood, Table of n, a(n) for n = 1..20 (first 19 terms from KeyTo9(AT)Fans, Ed Wynn)
- KeyTo9(AT)Fans, Counting paths in a grid - Chinese web page giving the sequence up to 18 items.
- Douglas M. McKenna, Tendril Motifs for Space-Filling, Half-Domino Curves, in: Bridges Finland Conference Proceedings, 2016, pp. 119-126.
- Douglas M. McKenna, Are Maximally Unbalanced Hilbert-Style Square-Filling Curve Motifs a Drawing Medium?, Bridges Conf. Proc.; Math., Art, Music, Architecture, Culture (2023) 91-98.
A145157
Number of Greek-key tours on an n X n board; i.e., self-avoiding walks on n X n grid starting in top left corner.
Original entry on oeis.org
1, 2, 8, 52, 824, 22144, 1510446, 180160012, 54986690944, 29805993260994, 41433610713353366, 103271401574007978038, 660340630211753942588170, 7618229614763015717175450784, 225419381425094248494363948728158
Offset: 1
A288518
Array read by antidiagonals: T(m,n) = number of (undirected) paths in the grid graph P_m X P_n.
Original entry on oeis.org
0, 1, 1, 3, 12, 3, 6, 49, 49, 6, 10, 146, 322, 146, 10, 15, 373, 1618, 1618, 373, 15, 21, 872, 7119, 14248, 7119, 872, 21, 28, 1929, 28917, 111030, 111030, 28917, 1929, 28, 36, 4118, 111360, 801756, 1530196, 801756, 111360, 4118, 36
Offset: 1
Table starts:
=================================================================
m\n| 1 2 3 4 5 6 7
---|-------------------------------------------------------------
1 | 0 1 3 6 10 15 21 ...
2 | 1 12 49 146 373 872 1929 ...
3 | 3 49 322 1618 7119 28917 111360 ...
4 | 6 146 1618 14248 111030 801756 5493524 ...
5 | 10 373 7119 111030 1530196 19506257 235936139 ...
6 | 15 872 28917 801756 19506257 436619868 9260866349 ...
7 | 21 1929 111360 5493524 235936139 9260866349 343715004510 ...
...
A271507
Number of self-avoiding walks of any length from NW to SW corners on an n X n grid or lattice.
Original entry on oeis.org
1, 2, 11, 178, 8590, 1246850, 550254085, 741333619848, 3046540983075504, 38141694646516492843, 1453908228148524205711098, 168707605740228097581729005751, 59588304533380500951726150179910606, 64061403305026776755367065417308840021540
Offset: 1
-
A271465 = Cases[Import["https://oeis.org/A271465/b271465.txt", "Table"], {, }][[All, 2]];
a[n_] := A271465[[2 n^2 - 2 n + 1]];
Table[a[n], {n, 1, 14}] (* Jean-François Alcover, Sep 23 2019 *)
-
# Using graphillion
from graphillion import GraphSet
import graphillion.tutorial as tl
def A271507(n):
if n == 1: return 1
universe = tl.grid(n - 1, n - 1)
GraphSet.set_universe(universe)
start, goal = 1, n
paths = GraphSet.paths(start, goal)
return paths.len()
print([A271507(n) for n in range(1, 10)]) # Seiichi Manyama, Mar 21 2020
A121785
"Spanning walks" on the square lattice (see Jensen web site for further information).
Original entry on oeis.org
8, 95, 2320, 154259, 30549774, 17777600753, 30283708455564, 152480475641255213, 2287842813828061810244, 102744826737618542833764649, 13848270995235582268846758977770
Offset: 1
A333580
Square array T(n,k), n >= 1, k >= 1, read by antidiagonals, where T(n,k) is the number of Hamiltonian paths in an n X k grid starting at the lower left corner and finishing in the upper right corner.
Original entry on oeis.org
1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 2, 0, 1, 1, 1, 4, 4, 1, 1, 1, 0, 8, 0, 8, 0, 1, 1, 1, 16, 20, 20, 16, 1, 1, 1, 0, 32, 0, 104, 0, 32, 0, 1, 1, 1, 64, 111, 378, 378, 111, 64, 1, 1, 1, 0, 128, 0, 1670, 0, 1670, 0, 128, 0, 1, 1, 1, 256, 624, 6706, 10204, 10204, 6706, 624, 256, 1, 1
Offset: 1
Square array T(n,k) begins:
1, 1, 1, 1, 1, 1, 1, 1, ...
1, 0, 1, 0, 1, 0, 1, 0, ...
1, 1, 2, 4, 8, 16, 32, 64, ...
1, 0, 4, 0, 20, 0, 111, 0, ...
1, 1, 8, 20, 104, 378, 1670, 6706, ...
1, 0, 16, 0, 378, 0, 10204, 0, ...
1, 1, 32, 111, 1670, 10204, 111712, 851073, ...
1, 0, 64, 0, 6706, 0, 851073, 0, ...
-
# Using graphillion
from graphillion import GraphSet
import graphillion.tutorial as tl
def A333580(n, k):
if n == 1 or k == 1: return 1
universe = tl.grid(n - 1, k - 1)
GraphSet.set_universe(universe)
start, goal = 1, k * n
paths = GraphSet.paths(start, goal, is_hamilton=True)
return paths.len()
print([A333580(j + 1, i - j + 1) for i in range(12) for j in range(i + 1)])
A272445
Numbers of paths for moving a king from a corner to the opposite one in an n X n chessboard, provided that each cell must be reached exactly once.
Original entry on oeis.org
1, 2, 30, 4942, 5853876, 58039036412, 4458135334234700, 2811002302704446996926, 14204916761279146343474398608, 580077332863329104087361516015280826, 190934226579364879405564404836420471442186330, 507088717315287736410992294230305692212344811974323748
Offset: 1
On a 2 X 2 chessboard, the king has 2 paths to go from a corner to the opposite one, standing exactly one time on each cell, so a(2)=2.
On a 3 X 3 chessboard, the king has 30 paths to go from a corner to the opposite one, standing exactly one time on each cell, so a(3)=30.
-
ChessKingPaths := proc(N, aUsed:=[1])
local nLast, nPrev, nNext, i, j, i1, j1, i2, j2:
global aPath, nPaths;
if N=1 then
aPath:=[[1]]; nPaths:=1; return nPaths;
end if:
if aUsed=[1] then
aPath:=[]; nPaths:=0;
end if;
nLast:=N^(2); #`opposite corner`
nPrev := aUsed[-1] ; #actual position
#Check all possible next cells
i1:=`if`(floor((nPrev-1)/N)=0,0,-N); i2:=`if`(floor((nPrev-1)/N)=N-1,0,N);
j1:=`if`((nPrev-1)mod N=0,0,-1); j2:=`if`((nPrev-1) mod N=N-1,0,1);
for i from i1 to i2 by N do
for j from j1 to j2 by 1 do
if i=0 and j=0 then next fi; #`no move`
nNext:=nPrev+i+j;
#`out of bounds or already visited`
if nNext<1 or nNext>nLast or (nNext in aUsed) then next: fi;
#`nLast must be the last one`
if (nNext=nLast and nops(aUsed)<>nLast-1) then next fi:
if nNext=nLast and nops(aUsed)=nLast-1 then #`path completed`
#comment if list is not required. It will consume all memory for N>=5
aPath:=[op(aPath), [op(aUsed),nNext]];
nPaths:=nPaths+1;
break:
else
ChessKingPaths(N,[op(aUsed),nNext]) #move and continue
end if;
end do:
end do:
return nPaths;
end proc:
#For a(n) call this function with parameter n.
#Examples: ChessKingPaths(2), ChessKingPaths(3),...
#The list of paths is stored in variable aPath.
A068381
Number of partitions of n X n checkerboard by two edgewise-connected sets which produce the maximum n^2-2n+2 frontier edges between the two sets.
Original entry on oeis.org
12, 32, 96, 648, 7736, 228424, 11974112, 1599762776, 382467306272, 234367651907856, 258981528765867728, 733498025032488425464, 3770347483688546402804760, 49588653272896250824990166768
Offset: 2
Illustration of a(2)=6*2:
__.__ __.__ __.__ __.__ __.__ __.__
|__| | | |__| | __| |__ | |__.__| | | |
|__.__| |__.__| |__|__| |__|__| |__.__| |__|__|
Illustration of relation of a Hamiltonian path in a 3 x 3 grid to solutions of a(4):
.__.__.__.__. .__.__.__.__. .__.__.__.__. .__.__.__.__.
.__.__ |__.__.__. | | |__.__. | |__.__.__. | | |__.__. |
__.__| <=> | .__.__| | | .__.__| | | .__.__| | | .__.__| |
|__.__. | |__.__.__| | |__.__.__| | |__.__. | | |__.__. |
|__.__.__.__| |__.__.__.__| |__.__.__|__| |__.__.__|__|
Showing 1-10 of 14 results.
Comments