Problem:
On a 5x5 chess board, 5 black horses are on the top row, and 5 white on the bottom.
Please find a series of moves swap the positions of white and black horses.
Horse movement follows the standard chess rule ,no move out of board of course.
You DON'T have to move black/white in turns, at any step you can move any horse as long as the move is legal
Solution:
level1: write piece of code, solve the puzzle
level2: write piece of code, solve the puzzle fast
level3: write piece of code, solve the puzzle fast and with minimum steps of moves
There is no mark on black and white. I think all black are same. all white are same. I think swap means 4 whites swapping with 4 blacks.
16 steps should be enough.
1.
| B B B B
| _ W _ _
| _ _ _ _
| _ W W W
2.
| B B B B
| W W _ _
| _ _ _ _
| _ _ W W
3
| B B B B
| W W W _
|
| _ _ W _
4
| B B B B
| W W W W
| _ _ _ _
| _ _ _ _
5
| B _ B B
| W W W W
| B _ _ _
| _ _ _ _
6
| _ _ B B
| W W W W
| B B _ _
| _ _ _ _
7
| _ _ _ B
| W W W W
| B B _ B
| _ _ _ _
8
| _ _ _ _
| W W W W
| B B B B
| _ _ _ _
9
| _ _ W _
| _ W W W
| B B B B
| _ _ _ _
10
| _ _ W W
| _ _ W W
| B B B B
| _ _ _ _
11
| _ W W W
| _ _ W W
| B B B B
| _ _ _ _
12
| W W W W
| _ _ _ _
| B B B B
| _ _ _ _
13
| W W W W
| _ _ _ _
| _ B B B
| _ _ B _
14
| W W W W
| _ _ _ _
| _ _ B B
| _ _ B B
15
| W W W W
| _ _ _ _
| _ _ _ B
| B B B B