Skip to content

Instantly share code, notes, and snippets.

@leonid-shevtsov
Last active September 3, 2024 20:22
Show Gist options
  • Save leonid-shevtsov/6ed346b5d73a681ffd49eb74ec27272b to your computer and use it in GitHub Desktop.
Save leonid-shevtsov/6ed346b5d73a681ffd49eb74ec27272b to your computer and use it in GitHub Desktop.
The goal: swap White and Black knights:
+-+
A |W|
+-+-+
B | | |
+-+-+-+
C | |W| |
+-+-+-+-+
D |B| |B| |
+-+-+-+-+
1 2 3 4
The way is clear if you turn the board into a graph:
W W B
A2 - C3 - D1 - B2 - C4 - D2 - B3 - D4 - C2
|
D3 B
The possible moves make a chain,
with only one appendix that will be used to swap piceces.
-> W W B
A2 - C3 - D1 - B2 - C4 - D2 - B3 - D4 - C2
|
D3 B
B <- W W B
A2 - C3 - D1 - B2 - C4 - D2 - B3 - D4 - C2
| ^
D3 |
B W W <-
A2 - C3 - D1 - B2 - C4 - D2 - B3 - D4 - C2
| V
D3 B
B -> W W
A2 - C3 - D1 - B2 - C4 - D2 - B3 - D4 - C2
|
D3 B
B B <- W W
A2 - C3 - D1 - B2 - C4 - D2 - B3 - D4 - C2
| ^
D3 |
B B W <-
A2 - C3 - D1 - B2 - C4 - D2 - B3 - D4 - C2
| V
D3 W
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment