# Puzzle | Four Alternating Knights

There are four knights on a 3 x 3 chessboard. The two white knights are at the two bottom corners, and the two black knights are at the upper two corners of the board. Find the shortest sequence of moves to achieve the final position as shown in the figure or prove that no such sequence exists.

## Recommended: Please try your approach on {IDE} first, before moving on to the solution.

Solution:

A knight in a game of chess has L-shaped moves. So, it can occupy at most two different positions in a single move on a 3 x 3 board. Consider a graph where vertices represent the cell number and the edges between them represent, the moves that various knights can make.

In this graph, we have two knights of the black color, followed by two knights of white color. Let’s consider knight at cell 1 moves to cell 6. Now to move to its final position cell 7, the knight at cell 7 should move to cell 2. However, its final position is cell 1 as shown. So the asked configuration is impossible to achieve. This is true for any sequence of moves, whether clockwise or counter-clockwise, as the ordering of the knights remains the same. However, the final configuration in question demands an alternating colored sequence of knights. So, this puzzle has no solution.

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

Article Tags :
Practice Tags :

3

Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.