%I #17 Feb 16 2025 08:34:01
%S 1,48,392,4678,43676,406396,3568906,30554390,254834078,2085479610,
%T 16791859330,133416458104,1048095087616,8154539310958,62918331433308,
%U 481954854686434,3668399080453520,27766093432542984,209120844634276158,1568050593805721822
%N Number of (undirected) Hamiltonian paths in the 3 X n king graph.
%H Andrew Howroyd, <a href="/A339761/b339761.txt">Table of n, a(n) for n = 1..200</a>
%H Eric Weisstein's World of Mathematics, <a href="https://mathworld.wolfram.com/GraphPath.html">Graph Path</a>
%H Eric Weisstein's World of Mathematics, <a href="https://mathworld.wolfram.com/KingGraph.html">King Graph</a>
%H <a href="/index/Rec#order_16">Index entries for linear recurrences with constant coefficients</a>, signature (15,-36,-289,708,2617,-1278,-4641,2263,4808,3286,-1422,-3830,-2200, -432,216,216).
%F G.f.: x*(1 + 33*x - 292*x^2 + 815*x^3 + 782*x^4 - 3649*x^5 - 4630*x^6 + 1517*x^7 + 3835*x^8 - 3822*x^9 - 5722*x^10 - 5418*x^11 - 7562*x^12 - 4808*x^13 - 240*x^14 + 720*x^15 + 216*x^16)/((1 - x)*(1 - 4*x - 15*x^2 - 8*x^3 - 6*x^4)^2*(1 - 6*x - 12*x^2 + 27*x^3 - 2*x^4 - 30*x^5 - 4*x^6 + 6*x^7)). - _Andrew Howroyd_, Jan 17 2022
%o (Python)
%o # Using graphillion
%o from graphillion import GraphSet
%o def make_nXk_king_graph(n, k):
%o grids = []
%o for i in range(1, k + 1):
%o for j in range(1, n):
%o grids.append((i + (j - 1) * k, i + j * k))
%o if i < k:
%o grids.append((i + (j - 1) * k, i + j * k + 1))
%o if i > 1:
%o grids.append((i + (j - 1) * k, i + j * k - 1))
%o for i in range(1, k * n, k):
%o for j in range(1, k):
%o grids.append((i + j - 1, i + j))
%o return grids
%o def A(start, goal, n, k):
%o universe = make_nXk_king_graph(n, k)
%o GraphSet.set_universe(universe)
%o paths = GraphSet.paths(start, goal, is_hamilton=True)
%o return paths.len()
%o def B(n, k):
%o m = k * n
%o s = 0
%o for i in range(1, m):
%o for j in range(i + 1, m + 1):
%o s += A(i, j, n, k)
%o return s
%o def A339761(n):
%o return B(n, 3)
%o print([A339761(n) for n in range(1, 11)])
%Y Row 3 of A350729.
%Y Cf. A003685, A308129, A339751, A339760, A339762, A339763.
%K nonn,changed
%O 1,2
%A _Seiichi Manyama_, Dec 16 2020