login
A396936
A knight starts at the origin on an infinite chessboard. In each step, it makes a knight's move to the unvisited point closest to the origin, avoiding steps that inevitably lead to a dead end at some point in the future. See comments for how ties are resolved. a(n) is the x-coordinate of the knight after the n-th step.
4
0, 2, 1, -1, 1, 0, -1, 1, -1, 0, 2, 1, -1, -2, 0, 2, 3, 1, -1, -2, 0, 2, 0, -1, -2, -1, 1, 3, 4, 3, 1, -1, -2, -3, -2, 0, 2, 3, 2, 0, -2, -3, -4, -3, -2, 0, 2, 4, 3, 2, 0, -2, -3, -4, -3, -2, -4, -2, -3, -4, -3, -1, 1, 3, 4, 5, 4, 3, 1, -1, -3, -4, -5, -6, -4
OFFSET
0,2
COMMENTS
If there is more than one possible move with the same distance to the origin, the length of the 2nd difference ("acceleration") is minimized, then the length of the 3rd difference is minimized, etc (see example). (The 1st differences always have length sqrt(5), so there is no point in comparing them.) If there is still a tie after comparing the n-th differences (using all previous points on the path), the lexicographically largest point is chosen. This last rule seems never to come into play, except for the very first step.
Backtracking (discarding a candidate move because it inevitably leads to a dead end) is needed for the first time in the 92068th step, in which the step to (62,-158) is discarded because all its neighbors are already visited. Instead the knight moves to (65,-159). (62,-158) is also the position closest to the origin of the positions that are never visited. Among the first 1000000 steps, backtracking is needed 22 times.
The first time the 3rd differences need to be compared is at the 1793rd step (see example). Among the first 1000000 steps, differences of order higher than 3 never need to be compared; 3rd differences are needed 11 times.
EXAMPLE
After the 1792nd step the knight is at (20,-10). The positions (18,-9), (19,-8), and (18,-11) with distances sqrt(405), sqrt(425), and sqrt(445) to the origin, respectively, are already visited. Of the remaining candidate points, (21,-8) and (19,-12) are closest to the origin at distance sqrt(505). The positions preceding (20,-10) are (20,-12) and (22,-11). For the candidate (21,-8), the successive differences are as follows:
(20,-12) (22,-11) (20,-10) (21, -8);
( 2, 1) (-2, 1) ( 1, 2);
(-4, 0) ( 3, 1);
( 7, 1).
For the candidate (19,-12) the successive differences are:
(20,-12) (22,-11) (20,-10) (19,-12);
( 2, 1) (-2, 1) (-1, -2);
(-4, 0) ( 1, -3);
( 5, -3).
The 2nd differences (3,1) and (1,-3) both have length sqrt(10), but the third differences (7,1) and (5,-3) have lengths sqrt(50) and sqrt(34), respectively, so the 2nd candidate (19,-12) is preferred. (This is the first time the 3rd differences need to be compared.) To be certain that the point (19,-12) is actually chosen, one should also verify that it is still possible to continue the path indefinitely from the chosen point, which is the case here.
CROSSREFS
Cf. A316328, A326924, A396937 (y-coordinates), A397388, A397392.
Sequence in context: A261029 A117195 A156606 * A324606 A194087 A107034
KEYWORD
sign,changed
AUTHOR
STATUS
approved