Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/stylextv/towers-of-hanoi
https://github.com/stylextv/towers-of-hanoi
Last synced: 25 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/stylextv/towers-of-hanoi
- Owner: stylextv
- License: gpl-3.0
- Created: 2022-09-12T09:19:16.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-09-12T09:40:02.000Z (over 2 years ago)
- Last Synced: 2024-10-14T06:35:56.703Z (2 months ago)
- Language: Java
- Size: 18.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Towers of Hanoi
This is a simple program that recursively computes a list of instructions for the optimal solution to the [Towers of Hanoi puzzle](https://en.wikipedia.org/wiki/Tower_of_Hanoi) for any given amount of disks `n`.
Said optimal solution will contain exactly2n - 1
moves.Program output:
```java
n = 5
0 -> 2
0 -> 1
2 -> 1
0 -> 2
1 -> 0
1 -> 2
0 -> 2
0 -> 1
2 -> 1
2 -> 0
1 -> 0
2 -> 1
0 -> 2
0 -> 1
2 -> 1
0 -> 2
1 -> 0
1 -> 2
0 -> 2
1 -> 0
2 -> 1
2 -> 0
1 -> 0
1 -> 2
0 -> 2
0 -> 1
2 -> 1
0 -> 2
1 -> 0
1 -> 2
0 -> 2
solved = true
```