A333795
Number of self-avoiding closed paths on an n X n grid which pass through all points on the two diagonals of the grid.
Original entry on oeis.org
1, 0, 6, 68, 6102, 1404416, 1094802826, 2524252113468
Offset: 2
a(2) = 1;
+--+
| |
+--+
a(4) = 6;
+--*--*--+ +--*--*--+ +--*--*--+
| | | | | |
*--+--+ * *--+ +--* * +--+--*
| | | | | |
*--+--+ * *--+ +--* * +--+--*
| | | | | |
+--*--*--+ +--*--*--+ +--*--*--+
+--*--*--+ +--* *--+ +--* *--+
| | | | | | | | | |
* +--+ * * +--+ * * + + *
| | | | | | | | | |
* + + * * +--+ * * +--+ *
| | | | | | | | | |
+--* *--+ +--* *--+ +--*--*--+
-
# Using graphillion
from graphillion import GraphSet
import graphillion.tutorial as tl
def A333795(n):
universe = tl.grid(n - 1, n - 1)
GraphSet.set_universe(universe)
cycles = GraphSet.cycles()
points = [i + 1 for i in range(n * n) if i % n - i // n == 0 or i % n + i // n == n - 1]
for i in points:
cycles = cycles.including(i)
return cycles.len()
print([A333795(n) for n in range(2, 10)])
A333796
Number of self-avoiding closed paths on an n X n grid which pass through all points on the diagonal connecting NW and SE corners.
Original entry on oeis.org
1, 2, 22, 716, 73346, 23374544, 23037365786, 69630317879888
Offset: 2
a(2) = 1;
+--*
| |
*--+
a(3) = 2;
+--*--* +--*
| | | |
*--+ * * +--*
| | | |
*--+ *--*--+
a(4) = 22;
+--*--*--* +--*--*--* +--*--*--*
| | | | | |
*--+--* * *--+--* * *--+--* *
| | | | | |
*--*--+ * *--+ * + *
| | | | | |
*--*--*--+ *--*--+ *--+
+--*--*--* +--*--*--* +--*--*--*
| | | | | |
*--+ *--* *--+ *--* *--+ *
| | | | | |
*--* +--* * +--* *--+ *
| | | | | |
*--*--*--+ *--*--+ *--+
+--*--*--* +--*--*--* +--*--*--*
| | | | | |
* +--*--* * +--* * * +--* *
| | | | | | | | | |
* *--+--* *--* + * * * + *
| | | | | | | |
*--*--*--+ *--+ *--* *--+
+--*--* +--*--* +--*--*
| | | | | |
*--+ *--* *--+ * *--+ *
| | | | | |
*--+ * *--* +--* * +--*
| | | | | |
*--+ *--*--*--+ *--*--+
+--*--* +--* *--* +--* *--*
| | | | | | | | | |
* +--* * +--* * * +--* *
| | | | | |
* *--+--* *--*--+ * * *--+ *
| | | | | | | |
*--*--*--+ *--+ *--* *--+
+--* *--* +--* +--*
| | | | | | | |
* + * * * +--*--* * +--*--*
| | | | | | | |
* *--+ * *--*--+ * * *--+ *
| | | | | | | |
*--*--*--+ *--+ *--* *--+
+--* +--* +--*
| | | | | |
* +--* * +--* * + *--*
| | | | | | | |
*--* +--* * +--* * *--+ *
| | | | | |
*--*--+ *--*--*--+ *--*--*--+
+--*
| |
* +
| |
* *--+--*
| |
*--*--*--+
-
# Using graphillion
from graphillion import GraphSet
import graphillion.tutorial as tl
def A333796(n):
universe = tl.grid(n - 1, n - 1)
GraphSet.set_universe(universe)
cycles = GraphSet.cycles()
points = [i + 1 for i in range(n * n) if i % n - i // n == 0]
for i in points:
cycles = cycles.including(i)
return cycles.len()
print([A333796(n) for n in range(2, 10)])
Showing 1-2 of 2 results.
Comments