Towers of Hanoi: Difference between revisions

→‎{{header|Python}}: The code was buggy: ndisks is the number of disks to be moved (recursively) and not the index of the disk to be moved.
(→‎{{header|Python}}: The code was buggy: ndisks is the number of disks to be moved (recursively) and not the index of the disk to be moved.)
Line 1,418:
if ndisks:
hanoi(ndisks-1, startPeg, 6-startPeg-endPeg)
print "Move disk %d from peg %d to peg %d" % (ndisks, startPeg, endPeg)
hanoi(ndisks-1, 6-startPeg-endPeg, endPeg)
 
Anonymous user