How to work Towers of Hanoi code in typescript?


This Content is from Stack Overflow. Question asked by Bernard

Here I was able to replicate a python version to typescript of Towers of Hanoi after fixing some errors I was not able to run it, I tried every option to switch some of the code but it still doesn’t run. A little guide of what went wrong of my Towers of Hanoi code. Here’s the code.

let A = [1, 2, 3];

let B = [];
let C = [];

function move(n, source, auxiliary, target) {
if (n > 0) {
move(n, source, target, auxiliary)
console.log(‘##############’, n);
move(n – 1, auxiliary, source, target);

move(3, A, B, C);


This question is not yet answered, be the first one who answer using the comment. Later the confirmed answer will be published as the solution.

This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?