Towers of Hanoi: Difference between revisions

m
Line 3,579:
const go = hanoi(n - 1);
 
return Boolean(n) ? [
...go(a,? c, b),[
...[go(a, c, b),
[a, b],
] ...go(c, b, a)
...go(c, b, a)]
] : [];
};
 
Line 3,591:
// ---------------------- TEST -----------------------
return hanoi(3)("left", "right", "mid")
.map(d => `${d[0]} -> ${d[1]}`)
.join("\n");
})();</syntaxhighlight>
{{Out}}
9,659

edits