我覺得我的漢諾塔答案是對的,但是沒過???
def move(n, a, b, c):
? ? x = n
? ? if n == 1:
? ? ? ? print a,'-->',c
? ? ? ? return
? ? while x > 1:
? ? ? ? print a,'-->',b
? ? ? ? x -= 1
? ? print a,'-->',c
? ? n -= 1
? ? d = a
? ? a = b
? ? b = d
? ? move(n, a, b, c)
move(4, 'A', 'B', 'C')
2018-08-13
往b上移,第二個放b上肯定下面的大,不符合規則
2018-08-13
?while x > 1:
? ? ? ? print a,'-->',b
? ? ? ? x -= 1
這個會對嗎,只是針對n=4對吧