# Exchange pawns (sliding block puzzle)

How many moves are needed to exchange the positions of black and white pawns? That is, all black pawns should be located at the below line and vice versa. But, all black pawns are identical and so are all white pawns.

Each pawn can be moved to an adjacent blank square.

• Normal chess rules don't apply?
– ACB
Mar 8, 2023 at 2:09
• @ACB No. Each pawn moves just four direction: up, down, left, right. Mar 8, 2023 at 3:35
• If the two blank spaces are together and a pawn moves two steps at once, does that count as one move or two? Mar 8, 2023 at 6:15
• @JaapScherphuis I would count it as two moves because it is natural and convenient for computer programming. Of course, someone may prefer one move. Mar 8, 2023 at 13:42

I used a computer to find an optimal solution.

52 moves.

 52 BBBBB    39 BBB.W    26 BBW.W    13 B.WWW
X.X.X       XBX.X       XBXWX       X.XWX
WWWWW       WBWWW       B.WBW       BBBWB

51 B.BBB    38 BBB.W    25 BBWWW    12 .BWWW
XBX.X       XBXWX       XBX.X       X.XWX
WWWWW       WBW.W       B.WBW       BBBWB

50 BB.BB    37 BBBWW    24 BBWWW    11 ..WWW
XBX.X       XBX.X       XBX.X       XBXWX
WWWWW       WBW.W       BW.BW       BBBWB

49 BBB.B    36 BBBWW    23 BBWWW    10 .W.WW
XBX.X       XBX.X       XBX.X       XBXWX
WWWWW       WB.WW       BWB.W       BBBWB

48 BBBB.    35 BBBWW    22 BBWWW    9  W..WW
XBX.X       XBX.X       XBX.X       XBXWX
WWWWW       W.BWW       BWBW.       BBBWB

47 BBBB.    34 BBBWW    21 BBWWW    8  W.W.W
XBXWX       XBX.X       XBXWX       XBXWX
WWW.W       .WBWW       BWB..       BBBWB

46 BBBB.    33 BBBWW    20 BBWWW    7  W.WWW
XBXWX       XBXWX       XBXWX       XBX.X
WW.WW       .WB.W       BW.B.       BBBWB

45 BBBB.    32 BBBWW    19 BBWWW    6  WW.WW
XBXWX       XBXWX       XBXWX       XBX.X
W.WWW       .W.BW       BW..B       BBBWB

44 BBBB.    31 BBBWW    18 BBWWW    5  WWW.W
X.XWX       XBXWX       XBXWX       XBX.X
WBWWW       ..WBW       B.W.B       BBBWB

43 B.BB.    30 BBBWW    17 BBWWW    4  WWW.W
XBXWX       X.XWX       X.XWX       XBXWX
WBWWW       .BWBW       BBW.B       BBB.B

42 BB.B.    29 B.BWW    16 BBWWW    3  WWW.W
XBXWX       XBXWX       X.XWX       XBXWX
WBWWW       .BWBW       BB.WB       BB.BB

41 BBB..    28 BB.WW    15 B.WWW    2  WWW.W
XBXWX       XBXWX       XBXWX       XBXWX
WBWWW       .BWBW       BB.WB       B.BBB

40 BBBW.    27 BBW.W    14 B.WWW    1  WWWWW
XBX.X       XBXWX       XBXWX       XBX.X
WBWWW       .BWBW       B.BWB       B.BBB

0  WWWWW
X.X.X
BBBBB

A rearrangement of a few moves allows the solution to be broken up into clear stages, making it much easier to see what is going on.

 52 BBBBB
X.X.X
WWWWW

Rotate the ring anti-clockwise until spaces are at top right

43 BB..B
XBXWX
WBWWW

Swap top right corner

39 BBB.W
XBX.X
WBWWW

Rotate the ring anti-clockwise until spaces are at bottom left

33 BBBWW
XBXWX
W..BW

Swap bottom left corner

29 BBBWW
X.XWX
B.WBW

Shift the pieces in the ring left to bring spaces to the right bottom

23 BBWWW
XBX.X
BWB.W

Swap bottom right corner

19 BBWWW
XBXWX
BW..B

Rotate the ring anti-clockwise until spaces are at left top

13 B.WWW
X.XWX
BBBWB

Swap top left corner

9  W..WW
XBXWX
BBBWB

Rotate the ring anti-clockwise until all pieces are correct

0  WWWWW
X.X.X
BBBBB

• Great work! Would love to see an animation of this. Mar 9, 2023 at 2:57
• @DmitryKamenetsky Me, too! Mar 9, 2023 at 12:38

Not the optimal solution of 52 moves as the other answer presents, I managed to get 62 moves by trying to place correct pawns at the four corners first. Once each corner is solved and the remaining black and white pawns are all adjacent, then shifting them is trivial.