Skip to content

tomcss/hanoi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 

Repository files navigation

Hanoi Solutions Generator

A simple and quick solutions generator for any size Hanoi towers. This solver only generates solutions for standard Hanoi problems in the initial state; it can't solve scrambled puzzles.

Get all moves at once:

let hanoi = new HanoiSolver(3)
moves = hanoi.allMoves()
JSON.stringify(moves) // "[[1,3],[1,2],[3,2],[1,3],[2,1],[2,3],[1,3]]"

Get one move at a time:

let hanoi = new HanoiSolver(3)
let move = hanoi.nextMove()
while( move !== -1) {
    console.log( move);
    move = hanoi.nextMove();
}

About

Hanoi Solutions Generator

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors