login
A333466
Number of self-avoiding closed paths on an n X n grid which pass through four corners ((0,0), (0,n-1), (n-1,n-1), (n-1,0)).
9
1, 1, 11, 373, 44930, 17720400, 22013629316, 84579095455492
OFFSET
2,3
COMMENTS
a(11) = 36061721109572407840288. - Seiichi Manyama, Apr 07 2020
EXAMPLE
a(2) = 1;
+--+
| |
+--+
a(3) = 1;
+--*--+
| |
* *
| |
+--*--+
a(4) = 11;
+--*--*--+ +--*--*--+ +--*--*--+
| | | | | |
*--*--* * *--* *--* *--* *
| | | | | |
*--*--* * *--* *--* *--* *
| | | | | |
+--*--*--+ +--*--*--+ +--*--*--+
+--*--*--+ +--*--*--+ +--*--*--+
| | | | | |
* *--*--* * *--* * * *--*
| | | | | | | |
* *--*--* * * * * * *--*
| | | | | | | |
+--*--*--+ +--* *--+ +--*--*--+
+--*--*--+ +--*--*--+ +--* *--+
| | | | | | | |
* * * * * *--* *
| | | | | |
* *--* * * * * *--* *
| | | | | | | | | |
+--* *--+ +--*--*--+ +--* *--+
+--* *--+ +--* *--+
| | | | | | | |
* *--* * * * * *
| | | | | |
* * * *--* *
| | | |
+--*--*--+ +--*--*--+
PROG
(Python)
# Using graphillion
from graphillion import GraphSet
import graphillion.tutorial as tl
def A333466(n):
universe = tl.grid(n - 1, n - 1)
GraphSet.set_universe(universe)
cycles = GraphSet.cycles()
for i in [1, n, n * (n - 1) + 1, n * n]:
cycles = cycles.including(i)
return cycles.len()
print([A333466(n) for n in range(2, 10)])
(Ruby)
def search(x, y, n, used)
return 0 if x < 0 || n <= x || y < 0 || n <= y || used[x + y * n]
return 1 if x == 0 && y == 1 && [n - 1, n * (n - 1), n * n - 1].all?{|i| used[i] == true}
cnt = 0
used[x + y * n] = true
@move.each{|mo|
cnt += search(x + mo[0], y + mo[1], n, used)
}
used[x + y * n] = false
cnt
end
def A(n)
return 1 if n < 3
@move = [[1, 0], [-1, 0], [0, 1], [0, -1]]
used = Array.new(n * n, false)
search(0, 0, n, used)
end
def A333466(n)
(2..n).map{|i| A(i)}
end
p A333466(6)
CROSSREFS
Main diagonal of A333513.
Sequence in context: A291973 A024149 A353934 * A018893 A051862 A006698
KEYWORD
nonn,more
AUTHOR
Seiichi Manyama, Mar 22 2020
STATUS
approved