0
点赞
收藏
分享

微信扫一扫

bx01_hanoi_recursion

陆公子521 2022-02-10 阅读 80
def hanoi(n, a, b, c):

    if n > 0:
        hanoi(n - 1, a, c, b)
        print(f'moving from {a} to {c}')
        hanoi(n-1, b, a, c)


hanoi(3, 'A', 'B', 'C')
举报

相关推荐

0 条评论