Quick implementation for solving the Towers of Hanoi puzzle and an animation
Go to file
2024-10-18 22:27:12 +02:00
.gitignore Initial commit 2024-10-18 20:48:09 +02:00
animation.py Refactorization 2024-10-18 21:50:35 +02:00
game.py Rename main.py to game.py as it makes more sense 2024-10-18 21:51:48 +02:00
movie.gif Add animation examples 2024-10-18 21:52:00 +02:00
movie.mp4 Add animation examples 2024-10-18 21:52:00 +02:00
README.md Add a simple README 2024-10-18 22:27:12 +02:00

Towers of Hanoi

Alt text

Small repo with two scripts around the popular Towers of Hanoi puzzle. I decided to do this after having lunch with some friends which were a few courses ahead of me in CS, and they talked about this puzzle, and I had never thought of solving it with a computer, and I thought it would be a fun and simple CP challenge for myself, so I sat in front of the computer that(this) evening and this is what came out.

  • game.py: A simple implementation of the game, which also includes a solver which I created when trying to solve the problem without ever having seen the solution (but it finds the optimal solution nonetheless)

  • animation.py: Creates/shows an animation of the optimal solution (in 2^n-1 moves with n as number of disks). Execute it with python3 animation.py -h to see how to use it. It generated the gif on top of this file