'How to solve the Guarini problem BUT on a 3x4 board, and with six knights instead using DIVIDE AND CONQUER?
enter image description hereThere are six knights on a 3 × 4 chessboard: the three white knights are at the bottom row, and the three black knights are at the top row. Design a divide and conquer algorithm to exchange the knights to get the position shown on the right of the figure in the minimum number of knight moves, not allowing more than one knight on a square at any time.
I've solved this problem above using backtracking but I'm trying to solve it using Divide and Conquer. I know it's not the optimal algorithm, but using it is a must. I understand divide and conquer, but I don't know how to apply it to this problem.
I've thought of a couple solutions so far, but each of them has certain problems that don't achieve the conditions mentioned in the problem statement above and I can't transform them into code easily.
Solution 1:
Solved it in 16 moves, where we implement a transform and conquer algorithm that transfers the chessboard into a graph, the nodes of this graph would be the possible moves from each tile.
Its Problem: I can't figure out how to divide it into subproblems
Solution 2:
Solved it in 18 moves, where every two knights are a subproblem.
Its Problem: The code I create must decide the next move on its own of course. However, following this solution, each knight's next move doesn't follow any clear pattern I can transform into code.
Visualizing the chessboard as follows:
B1 B2 B3
. . .
. . .
W1 W2 W3
Where the tiles are numbered as follows:
1 2 3
4 5 6
7 8 9
10 11 12
Each knight will move according to the following steps:
B1: 1, 6, 7
W2: 11, 6, 1
B1: 7, 6, 11
W3: 12, 7, 6
B2: 2, 7, 12
W1: 10, 9, 2
B3: 3, 4, 9, 10
W2: 1, 8, 3
W3: 6, 1
All I'm asking is, I'd be grateful if you have a possible solution for any of the previous problems OR if you have a new solution of your own.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
