Skip to content

Instantly share code, notes, and snippets.

@sjdonado
Created May 8, 2023 18:56
Tower of Hanoi in P5.js + WASM - Dev.to
function recursiveHanoi(A, C, B, n){
if (n == 1) {
moves.push(A + ":" + C);
} else {
recursiveHanoi(A, B, C, n - 1);
moves.push(A + ":" + C);
recursiveHanoi(B, C, A, n - 1);
}
}
function generateHanoiArray(disksNumber) {
var moves = [];
recursiveHanoi(0, 2, 1, disksNumber);
return moves;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment