Skip to content

Brute force solution to the Chess puzzle that got June Huh interested in Maths

License

Notifications You must be signed in to change notification settings

djiti/jh-chess-puzzle

Repository files navigation

Original idea

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:

However, we could not resist and used a property.

Running

./chess.py 
*********************
In 41 moves, visiting 1259 layouts (excluding the final one):

 ♘  
 □□ 
 □♘□
♞□♞□

 ♘  
 ♞□ 
 □♘□
□□♞□

 ♘  
 □□ 
 □♘♞
□□♞□

 ♘  
 □□ 
 □□♞
♘□♞□
[...]

Testing

python3 -m pytest

Or if you are in a hurry and installed pytest-xdist:

python3 -m pytest -n 3

Developing

Everybody can just use their favorite Python IDE.

"Geeks" can use Docker and VS Code's devcontainer extension.

About

Brute force solution to the Chess puzzle that got June Huh interested in Maths

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages