汉诺塔 python实现

def hanoi(N,base,asist,destination):
    if N==1:
       #move(1,base,destination)
       print('Move disk from {} to {}'.format(base, destination) ) 
    else:
        hanoi(N-1,base,destination,asist)
        #move(1,base,destination)
        print('Move disk from {} to {}'.format(base, destination) )
        hanoi(N-1,asist,base,destination)

你可能感兴趣的:(汉诺塔 python实现)