# -*- coding: utf-8 -*-
def move(n, a, b, c):
if n == 1:
print(a, '-->', c)
step.append(0)
else:
move(n-1,a,c,b)
move(1,a,b,c)
move(n-1,b,a,c)
n = int(input('amount of plates: '))
step = []
move(n, 'A', 'B', 'C')
print ('总共使用了 %d 步' % len(step))
Sign in to make a reply
忆往昔念往昔往昔不复悔不当初
# -*- coding: utf-8 -*-
def move(n, a, b, c):
if n == 1:
print(a, '-->', c)
step.append(0)
else:
move(n-1,a,c,b)
move(1,a,b,c)
move(n-1,b,a,c)
n = int(input('amount of plates: '))
step = []
move(n, 'A', 'B', 'C')
print ('总共使用了 %d 步' % len(step))