Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/stylextv/towers-of-hanoi


https://github.com/stylextv/towers-of-hanoi

Last synced: 25 days ago
JSON representation

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 exactly 2n - 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
```