Hanoi recursive implementation in JS
Function: hanoi(n, src, use, dst)
n - rings #
src, use, dst - tower # (e.g. 1, 2, 3)
Algorithm:
To move n rings use hanoi(n=10, src=1, use=2, dst=3) which does:
- Call hanoi to move n-1 rings from src to use using dst
- Move the last ring from src to dst
- Call hanoi to move n-1 from use to dst, using src