cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A272469 Numbers of n-step paths of a king moving on an n X n chessboard, starting at a corner and not visiting any cell twice.

This page as a plain text file.
%I A272469 #30 Jan 08 2019 12:29:45
%S A272469 0,6,50,322,1874,10558,58716,325758,1808778,10068548,56213606,
%T A272469 314785072,1767660604,9951449844,56151698716,317484868212,
%U A272469 1798343124800,10203031413894
%N A272469 Numbers of n-step paths of a king moving on an n X n chessboard, starting at a corner and not visiting any cell twice.
%e A272469 On an n X n chessboard, a king in a corner is allowed to have n moves. For n=2, let's name the cells A1,A2,B1,B2 with the king at A1. Two moves, without repeating cells, can be done in the following 6 different ways: {A1-A2-B1, A1-A2-B2, A1-B1-A2, A1-B1-B2, A1-B2-A2, A1-B2-B1}. So a(2)=6.
%p A272469 pathCount := proc (N)
%p A272469 local g1, g2, nStep, gg, nCells, nPrev, i1, i2, j1, j2, i, j, nNext;
%p A272469     nCells := N^2; g1 := [[1]];
%p A272469     if N = 1 then return nops(g1) fi; #forced value for N=0
%p A272469     for nStep to N do
%p A272469         g2 := [];
%p A272469         for gg in g1 do
%p A272469             nPrev := gg[-1];
%p A272469             i1 := `if`(floor((nPrev-1)/N) = 0, 0, -N);
%p A272469             i2 := `if`(floor((nPrev-1)/N) = N-1, 0, N);
%p A272469             j1 := `if`(`mod`(nPrev-1, N) = 0, 0, -1);
%p A272469             j2 := `if`(`mod`(nPrev-1, N) = N-1, 0, 1);
%p A272469             for i from i1 by N to i2 do
%p A272469                 for j from j1 to j2 do
%p A272469                     if i = 0 and j = 0 then next fi;
%p A272469                     nNext := nPrev+i+j;
%p A272469                     if nNext < 0 or nCells < nNext or (nNext in gg) then next fi;
%p A272469                     g2 := [op(g2), [op(gg), nNext]]
%p A272469                 end do
%p A272469             end do
%p A272469         end do;
%p A272469         g1 := g2
%p A272469     end do;
%p A272469     return nops(g1);
%p A272469 end proc:
%p A272469 [seq(pathCount(n), n = 1 .. 6)];
%Y A272469 Cf. A272445.
%K A272469 nonn,walk,more
%O A272469 1,2
%A A272469 _César Eliud Lozada_, Apr 30 2016
%E A272469 a(9)-a(16) from _Alois P. Heinz_, May 01 2016
%E A272469 a(17)-a(18) from _Bert Dobbelaere_, Jan 08 2019