I implemented this -> http://www.apl.jhu.edu/~hall/lisp/Hanoi.lisp in
both flavors of Python: 2.6.2 and 3.0.1 (CPython)

The code:
#!/usr/bin/env python
def remaining_peg (peg1, peg2):
        return (6 - peg1 - peg2)

def hanoi (num_discs, start, end):
        if (1 == num_discs):
                print "Top of peg {0} to peg {1}".format(start,end) # used 
print()
for Py 3.0.1

        else:
                hanoi ((num_discs - 1), start, (remaining_peg (start, end)))
                hanoi (1, start, end)
                hanoi ((num_discs - 1), (remaining_peg (start, end)), end)


hanoi(20,2,3)

The times:            real          usr          sys
Python 2.6.2       7.994s    3.336s   3.296s
Python 3.0.1       55.302s  38.024s 5.876s

What happened to Python?
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to