> For the complete documentation index, see [llms.txt](https://private-26.gitbook.io/notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://private-26.gitbook.io/notes/algorithmic-pattern/stack/tower-of-hanoi.md).

# Tower of Hanoi

The Tower of Hanoi puzzle (also called the Tower of Brahma or Lucas' Tower), has three pegs. One peg holds a stack of disks of different sizes, ordered from smallest to largest. The goal is to move all the disks from one peg to another. You must move disks one at a time, and you cannot place a disk on top of another disk that has a smaller radius

<figure><img src="https://2396813915-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FMQ6PIO0HHybjoa5n1vsw%2Fuploads%2F71aBzCbWKewSSiuPxzno%2Fc05f007.jpg?alt=media&amp;token=f5fed567-dfed-411d-9ef1-639fbc02203b" alt=""><figcaption><p>The goal in the Tower of Hanoi puzzle is to re-stack disks from one peg to another without placing a disk on top of a smaller disk.</p></figcaption></figure>
