Way to move the chess piece

41 Views Asked by At

Donald loves to play chess and often invents new pieces, making the game more interesting. Donald's chessboard is seen as a grid of $N$ lines and $M$ columns. The rows are numbered from $1$ to $N$ from top to bottom, the columns are numbered from $1$ to $M$ to the right. The intersection of row $x$ column $y$ is called cell $(x;y)$.

One day, he created a new piece by himself - piece $A$. The rule of this piece's movement is: if the piece is in cell $(x;y)$ then in the next step it can go to one of $4$ cell $(x,y+2),(x,y-2),(x-2,y)$ or $(x+2,y)$ provided that the cell is in the chessboard.

He wondered, if we put piece $A$ in cell $(x_1,y_1)$, would it be possible to move the piece to cell $(x_2,y_2)$, and if so, at least how many steps would it take for the piece to get there

This is actually an exercise using my Python computer language, but I like to think of it mathematically. I'm trying to split the cases, the first case is that $x_1$ and $y_1$ are both even, so $x_2$ and $y_2$ are both odd, so there's no way to move to this cell. Same with other cases. But I'm quite confused because I don't think the answer is that simple, please tell me if the above thought is right or wrong, and if it is wrong, please help me to solve this problem.