python

jiayou  •  18天前


a = int(input())

k = a
def f(n,a,b,c):
if n==k:
print(pow(2, k) - 1)
if n ==1:
print('Move {} to {}'.format(a,c))
return
else:
f(n-1,a,c,b)
print('Move {} to {}'.format(a, c))
f(n-1,b,a,c)
f(a,'A','B','C')


评论: