Guest User

Untitled

a guest
Jul 16th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.28 KB | None | 0 0
  1. function hanoi(n){
  2. const path = []
  3. function move(start=1,go=3, depth=n){
  4. if(depth===1) return path.push([start,go])
  5. else {
  6. const other = 6-(start+go)
  7. move(start, other, depth-1)
  8. move(start, go , 1)
  9. move(other, go, depth-1)
  10. }
  11. }
  12. move(1,3,n);
  13. return path;
  14. }
Add Comment
Please, Sign In to add comment