This Twitter post that Alex pointed at, along with this drawing:
The idea is to see how bad it is when we brute force the solution. A good "side effect" of the brute force approach is that it seems to prove we can visit all possible states from the original layout.
Take it as an attempt to introduce a few software engineering practices, but not too many. In particular, to avoid introducing too many Python concepts we are not using:
- type annotation even though we would really want to
- test fixtures
However, we could not resist and used a property.
./chess.py
*********************
In 41 moves, visiting 1259 layouts (excluding the final one):
♘
□□
□♘□
♞□♞□
♘
♞□
□♘□
□□♞□
♘
□□
□♘♞
□□♞□
♘
□□
□□♞
♘□♞□
[...]
python3 -m pytest
Or if you are in a hurry and installed pytest-xdist
:
python3 -m pytest -n 3
Everybody can just use their favorite Python IDE.
"Geeks" can use Docker and VS Code's devcontainer extension.