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.

A232007 Maximal number of moves needed by a knight to reach every square from a fixed position on an n X n chessboard, or -1 if it is not possible to reach every square.

Original entry on oeis.org

0, -1, -1, 5, 4, 4, 5, 6, 6, 7, 8, 8, 9, 10, 10, 11, 12, 12, 13, 14, 14, 15, 16, 16, 17, 18, 18, 19, 20, 20, 21, 22, 22, 23, 24, 24, 25, 26, 26, 27, 28, 28, 29, 30, 30, 31, 32, 32, 33, 34, 34, 35, 36, 36, 37, 38, 38, 39, 40, 40, 41, 42, 42, 43, 44, 44, 45, 46, 46
Offset: 1

Views

Author

Mateusz Szymański, Nov 16 2013

Keywords

Comments

In other words, a(n) is the graph diameter of the n X n knight graph (or -1 if the graph is disconnected). - Eric W. Weisstein, Nov 20 2019

Examples

			For a classic 8 X 8 chessboard, a knight needs at most 6 moves to reach every square starting from a fixed position, so a(8) = 6.
For a 3 X 3 chessboard, it's impossible to reach the middle square starting from any other, so a(3) = -1.
		

Crossrefs

Cf. A004523.

Programs

  • Mathematica
    Replace[Table[GraphDiameter[KnightTourGraph[n, n]], {n, 20}], Infinity -> -1] (* Eric W. Weisstein, Nov 20 2019 *)
    Join[{0, -1, -1, 5}, Table[Ceiling[2 n/3], {n, 5, 20}]] (* Eric W. Weisstein, Nov 20 2019 *)
    Join[{0, -1, -1, 5}, LinearRecurrence[{1, 0, 1, -1}, {4, 4, 5, 6}, 20]] (* Eric W. Weisstein, Nov 20 2019 *)
    CoefficientList[Series[-1 - x + 5 x^2 + x^3 (4 + x^2 - 3 x^3)/((-1 + x)^2 (1 + x + x^2)), {x, 0, 20}], x] (* Eric W. Weisstein, Nov 20 2019 *)
  • PARI
    concat(0, Vec(-x^2*(1-6*x^2+5*x^5-2*x^6)/((1-x)^2*(1+x+x^2)) + O(x^100))) \\ Colin Barker, Apr 26 2016

Formula

a(n) = ceiling(2n/3) for n > 4; see A004523. - R. J. Mathar, Nov 24 2013
From Colin Barker, Apr 26 2016: (Start)
a(n) = a(n-1)+a(n-3)-a(n-4) for n>8.
G.f.: -x^2*(1-6*x^2+5*x^5-2*x^6) / ((1-x)^2*(1+x+x^2)). (End)

Extensions

More terms from Vaclav Kotesovec, Oct 21 2014