Jump to content

Towers of Hanoi: Difference between revisions

(Added PL/M)
Line 4,951:
if ndisks:
hanoi(ndisks-1, startPeg, 6-startPeg-endPeg)
print (f"Move disk %d{ndisks} from peg %d{startPeg} to peg %d{endPeg}" % (ndisks, startPeg, endPeg)
hanoi(ndisks-1, 6-startPeg-endPeg, endPeg)
 
hanoi(ndisks=4)</lang>
{{out}} for ndisks=2
<pre>
Cookies help us deliver our services. By using our services, you agree to our use of cookies.