JSFiddle - React, Tailwind, and code Playground

by skwjdgn

JavaScript

const n = Math.round(Math.random()*100);


let hanoi = (n, from, temp, to) => {
    if(n===1) console.log(`${n}을 ${from}에서 ${to}로 이동`);
    else {
        hanoi(n-1, from, to, temp);
        console.log(`${n}을 ${from}에서 ${to}로 이동`);
        hanoi(n-1, temp, from, to);
    }
}
const n = Math.round(Math.random()*100);

hanoi(5, '1', '2', '3');