Discuss / Python / 结合下之前的知识

结合下之前的知识

Topic source

weareguyshot

#1 Created at ... [Delete] [Delete and Lock User]

def move(n,a='A',b='B',c='C'): if n < 0: print('out of range') return 1 if not isinstance(n,int): raise TypeError('bad operand type')

if n==1:
    print(a,'->',c)

else:
    move(n-1,a,c,b)
    move(1,a,b,c)
    move(n-1,b,a,c)

  • 1

Reply