A341195 Squares visited by knight moves on a diagonally back and forth numbered board in two quadrants and moving to the lowest available unvisited square at every step.
1, 11, 7, 2, 6, 12, 9, 3, 5, 14, 8, 4, 18, 33, 21, 29, 24, 26, 47, 10, 23, 13, 19, 16, 38, 34, 17, 15, 20, 30, 42, 56, 45, 28, 22, 31, 41, 58, 44, 32, 40, 35, 37, 62, 66, 36, 39, 60, 68, 63, 65, 98, 102, 64, 67, 61, 70, 93, 43, 55, 46, 27, 49, 52, 25, 51, 78
Offset: 1
Links
- Sander G. Huisman, Table of n, a(n) for n = 1..4408
- N. J. A. Sloane and Brady Haran, The Trapped Knight, Numberphile video (January, 2019).
Programs
-
Mathematica
(* Version 12.0 or higher needed *) ClearAll[ShowRoute,MakeMove,FindSequence] knightjump=Select[Tuples[Range[-2,2],2],Norm[#]==Sqrt[5]&]; ShowRoute[output_Association]:=Module[{colors},colors=(ColorData["Rainbow"]/@Subdivide[Length[output["Coordinates"]]-1.0]); Graphics[{Line[output["Coordinates"],VertexColors->colors],Disk[Last@output["Coordinates"],0.2],Style[Disk[Last[output["Coordinates"]]+#,0.2]&/@knightjump,Purple]}]] MakeMove[spiral_Association,visited_List]:=Module[{poss,hj},poss=Table[Last[Last[visited]]+hj,{hj,knightjump}]; poss=DeleteMissing[{spiral[#],#}&/@poss,1,\[Infinity]]; poss=Select[poss,FreeQ[visited[[All,2]],Last[#]]&]; If[Length[poss]>0,First[TakeSmallestBy[poss,First,1]],Missing[]]] FindSequence[start_:{0,0},grid_]:=Module[{positions,j,next},positions={{grid[start],start}}; PrintTemporary[Dynamic[j]]; Do[next=MakeMove[grid,positions]; If[next=!=Missing[],AppendTo[positions,next],Break[];],{j,\[Infinity]}]; <|"Coordinates"->positions[[All,2]],"Indices"->positions[[All,1]]|>] grid=ResourceFunction["LatticePointsArrangement"]["DiagonalZigZagEastQ34",20000]; grid=Association[MapIndexed[#1->#2[[1]]&,grid]]; ShowRoute[fs=FindSequence[{0,0},grid]] fs fs["Indices"] ListPlot[fs["Indices"]]
Comments