Towers of Hanoi: Difference between revisions

Content added Content deleted
(→‎{{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.)
(Undo revision 125368 by 206.75.102.162 (talk) last editor was confused)
Line 1,418: Line 1,418:
if ndisks:
if ndisks:
hanoi(ndisks-1, startPeg, 6-startPeg-endPeg)
hanoi(ndisks-1, startPeg, 6-startPeg-endPeg)
print "Move disk from peg %d to peg %d" % (startPeg, endPeg)
print "Move disk %d from peg %d to peg %d" % (ndisks, startPeg, endPeg)
hanoi(ndisks-1, 6-startPeg-endPeg, endPeg)
hanoi(ndisks-1, 6-startPeg-endPeg, endPeg)