2

I am trying to make a mathematical formula that determines the minimal amount of moves that is necessary for a knight to reach a square in a XxX board.

I have figured out that the knight moves can be converted to the numbers +-21,+-19,+-12,+-8 by multiplying the number of houses it can dislocate vertically/horizontally by then and adding it up to the number of houses it can dislocate horizontally/vertically.

2 houses vertically + 1 house horizontally = 210+1 2 houses vertically + -1 houses horizontally = 210+-1

and so on...

I figured also that a house can be transformed into a number into the same way as the knight moves.

So for me the solve the knight problem I just need a mathematical formula that reaches a determined number by summing and or subtracting zero to the numbers 21,19,12,8.

Example: A house in which is distant from the knight 2 houses vertically and 1 house horizontally or vice-versa represents the number 21 and the minimal amount of moves for the knight to reach it is 21, because there is a knight move that represents the number 21.

Could you please help me to figure out a formula?

I have thought some fancy ways to solve it, but I could not solve it. However, I figured out a cool mathematical axiom that goes like this:

Anyone number can be made up with the subtraction and or addition of two numbers different than zero without a mutual divider in which when subtracted by each the result of that subtraction is an odd number. That is because when the bigger number out of those two numbers is subtracted by the smaller one, the result is an odd number smaller than it. By repeating the process with the result and the smaller number of the last operation, the results will get increasingly smaller and the operations will always result in odd numbers. At some point of this process, the number 1 will be reaches, and any number can be made with the number one.

I made a list of numbers that can be formed with 21,19,12,8

1= 3 21-12-8 2= 2 21-19 3= 3 12+12-21 4= 2 12-8 5= 3 12-(19-12) 6= 3 8+21-19 7= 2 19-12 8= 1 8 9= 2 21-19 10= 3 21-19+8 11= 2 19-8 12 = 1 12 13 = 2 21-8 14= 3 21-19+12 15= 3 19-12+8 16= 2 8+8 17=21+8-12 18= ?? 19= 1 19 20= 2 12+8 21= 1 21 22= ?? 23= 3 19+12-8 24= 2 24 25= 3 21+12-8 26= 3 19+19-12 27= 2 19+8 28= 2 12+8+8 29= 2 21+8 30= 2 21+9

Thanks

XianLiu
  • 21
  • 3

1 Answers1

1

Here we derive a formula describing the minimum number of moves a knight needs to go from the origin $(0,0)$ to a point $(m,n)$. We encode the $8$ different knight moves algebraically by \begin{align*} xy^2, x^2y, x^2y^{-1},xy^{-2},x^{-1}y^{-2}, x^{-2}y^{-1},x^{-2}y,x^{-1}y^2 \end{align*} where for instance $xy^2$ means one horizontal step to the right and two vertical steps up. At first we look at the graphic where the number of moves is given for a distance up to $6$ from the origin and we check if we can find some patterns.

enter image description here

The graphic:

  • We see due to symmetry of the knight moves it is sufficient to consider the points $(x,y)$ in the first quadrant. We even see the symmetry between the first and second octant, so that is sufficient to restrict the analysis to the first octant \begin{align*} 0\leq y\leq x \end{align*}

  • Let's focus on the red colored $6$ at position $(12,4)$, which means that the knight needs a minimum number of $6$ moves to go from $(0,0)$ to $(12,4)$. Let's go back from $(12,4)$ to $(0,0)$. A convenient way is to successively move $x^{-2}y^{-1}$ till the $x$-axes is touched. This is indicated by the red dashed line which touches the $x$-axis at $(4,0)$. Here we need $y=4$ moves to go back from $(12,4)$ to $(4,0)$ and since $(4,0)$ is marked with $2$ we have to add $2$ to the $4$ moves giving a total of $6$ moves.

  • Going back from $(x,y)$ using $x^{-2}y^{-1}$ steps does not always touch the $x$-axis as we can see when starting from the green marked $6$ at position $(9,7)$. Following the green dashed line we see we touch the diagonal $x=y$ before the $x$-axis which is the other boundary of the first octant. Starting at $(9,7)$ we go $2$ moves back till $(5,5)$ (note: $y-x=9 - 7=2$). The point $(5,5)$ is marked with $4$ meaning that we have $4$ moves to add to $2$ giving a total of $6$ moves.

  • When do we touch the $x$-axis and when the diagonal? We observe:

    • If $x>2y$ we can write $(x,y)$ as \begin{align*} (x,y)=(x-2y,0)+(2y,y)\tag{1} \end{align*} which means we go $y$ times a move $x^{-2}y^{-1}$ from $(x,y)$ backwards till we touch the $x$-axis at $(x-2y,0)$.

    • If $x\leq 2y$ we can write $(x,y)$ as \begin{align*} (x,y)=(2y-x,2y-x)+(2x-2y,x-y)\tag{2} \end{align*} which means we go $x-y$ times a move $x^{-2}y^{-1}$ from $(x,y)$ backwards till we touch the diagonal at $(2y-x,2y-x)$.

In order to find a formula for the minimal number of moves from $(0,0)$ to $(x,y)$ we have to find the number of moves along the $x$-axis and the diagonal. Then we can add $y$ resp. $x-y$ moves depending on case (1) or (2).

$x$-axis:

Let $a(x,y)$ denote the minimal number of moves from $(0,0)$ to $(x,y)$, with $(x,y)$ a point in the first octant. We look at the values at the $x$-axis and see starting with $(x,0)=(2,0)$ a sequence organised in groups of $4$ values \begin{align*} \begin{array}{r|cccccccccccccccc} x&2&3&4&5&&6&7&8&9&&10&11&12&13&&\ldots\\ a(x,0)&2&3&2&3&\ &4&5&4&5&\ &6&7&6&7&&\ldots\tag{3} \end{array} \end{align*} We derive from (3) by inspection for $x\geq 2$: \begin{align*} \color{blue}{a(4n+k,0)=2n+k\qquad }&\color{blue}{n\geq 0, 0\leq k\leq 3}\tag{4}\\ \end{align*} We have the grey marked special case $a(1,0)=3$ which does not fit the formula (4) and which is therefore considered separately.

Diagonal:

We look at the values at the diagonal and see starting with $(x,y)=(3,3)$ a sequence organised in groups of $3$ values \begin{align*} \begin{array}{r|cccccccccccccccc} x&3&4&5&&6&7&8&&9&10&11&&\ldots\\ a(x,x)&2&4&4&\ &4&6&6&\ &6&8&8&&\ldots\tag{5} \end{array} \end{align*} We derive from (5) by inspection for $x\geq 3$: \begin{align*} \color{blue}{a(3n,3n)=2n\qquad }&\color{blue}{n\geq 0}\tag{6}\\ \color{blue}{a(3n+k,3n+k)=2n+2\qquad}&\color{blue}{n\geq 0, k=1,2} \end{align*} We have the grey marked special case $a(2,2)=4$ which does not fit the formula (6) and which is therefore considered separately.

A formula:

We are now well prepared to derive a formula for $a(x,y)$ with $0\leq y\leq x$.

Case $x>2y$:

Excluding the special case $a(1,0)=1$ we obtain from (1), (3) and (4): \begin{align*} (x,y)&=(x-2y,0)+(2y,y)\\ \color{blue}{a(x,y)}&=2\left\lfloor\frac{x-2y}{4}\right\rfloor+\left((x-2y)-4\left\lfloor\frac{x-2y}{4}\right\rfloor\right)+y\\ &\,\,\color{blue}{=x-y-2\left\lfloor\frac{x-2y}{4}\right\rfloor} \end{align*}

Case $x\leq 2y$:

Excluding the special case $a(2,2)=4$ we obtain from (2), (5) and (6): \begin{align*} (x,y)&=(2y-x,2y-x)+(2x-2y,x-y)\\ \color{blue}{a(x,y)}&\color{blue}{= \begin{cases} 2\left\lfloor\frac{2y-x}{3}\right\rfloor+x-y&2y-x\equiv 0(3)\\ \\ 2\left\lfloor\frac{2y-x}{3}\right\rfloor+2+x-y&2y-x\not \equiv 0(3)\\ \end{cases}} \end{align*}

Special cases:

Finally we list the two special cases \begin{align*} \color{blue}{a(1,0)=1}\\ \color{blue}{a(2,2)=4} \end{align*} which are due to the specific moves of the knight near the origin $(0,0)$ where also $a(2,-1)=a(-1,2)=1$ outside the first octant are needed to reach $(1,1)$ in a minimum number of $a(1,1)=2$ moves.

Markus Scheuer
  • 108,315