Skip to content
Switch branches/tags
Go to file
Cannot retrieve contributors at this time
53 lines (29 sloc) 1.81 KB

Tower of Hanoi

This piece of code intents to solve the Tower of Hanoi problem in a graphical way, probably making use of different methods.

The code display a Tower of Hanoi play set on the screen, using pyglet library, and start playing the game automatically. Discs start moving from column to column, playing the rule of the game, until the final configuration is achieved, when the game ends.

Game can be ended by pressing ESC key or closing the window.

You can find a real wooden Tower of Hanoi playset that I crafted here, which gave me the inspiration to write this piece of code. Tower of Hanoi wooden playset

You can check my blog entry on the problem: Rotpunkt Blog, Tower of Hanoi

Getting Started

Clone this repository on your local disk by executing. You will download as well other small projects

git clone


Install numpy and pyglet packages, these are available in the Python pip repository



The result of the execution should be a windows like the following one: Animation video


Add additional notes about how to deploy this on a live system


Feel free to contribute to this piece of code, maybe by adding a graphical interface



No licence for this project


  • pyglet library
  • Édouard Lucas for inventing the game