Discuss / Python / 交作业

交作业

Topic source

M斯蕾

#1 Created at ... [Delete] [Delete and Lock User]
def hanoi(n=1, a = 'a', b = 'b', c = 'c', i=1):
    if n == 1:
        print('%c --> %c' % (a, c))
    else:
        hanoi((n-1), a, c, b, i)
        hanoi(1, a, b, c, i)
        hanoi((n-1), b, a, c, i)
    print(i)

  • 1

Reply