Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/maximealgosup/tower-of-hanoi
https://github.com/maximealgosup/tower-of-hanoi
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/maximealgosup/tower-of-hanoi
- Owner: MaximeAlgosup
- License: mit
- Created: 2024-02-20T16:34:47.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-03-12T16:25:19.000Z (10 months ago)
- Last Synced: 2024-03-12T17:48:25.701Z (10 months ago)
- Language: Ruby
- Size: 46.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Tower-of-Hanoi
## Concept
Tower of Hanoi or Lucas' Tower is a mathematical puzzle created by the French mathematician Édourad Lucas.
The Tower of Hanoi has three rods (A, B, C) and N disks. Initially, all the disks are stacked in decreasing order of diameter, the smallest disk is at the top and they are on rod A. The puzzle aims to move the entire stack to another rod, obeying the following simple rules:
- Only one disk can be moved at a time.
- Each move consists of taking the top disk from one of the stacks and placing it on top of another stack, a disk can only be moved if it is the highest disk in a stack.
- No disc can be placed on top of a smaller disc.*Example of _what is supposed to look_ like*
## Usage
This algorithm is largely used to introduce people to algorithmic basics but also in psychology research.
## Algorithm
**Recursive implementation:**
The idea is to use the assistance node to reach the destination using recursion. Here's the model for this problem:
- Move disks "N-1" from "A" to "B", using C.
- Move the last disk from "A" to "C".
- Move disks "N-1" from "B" to "C", using A.
Picture from geekforgeek