Discuss / Python / 练手

练手

Topic source

月魂224

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

list = []def move(n, a, b, c):    if n == 1:        print(a, '-->', c)        list.append(f"{a}-->{c}")    else:        move(n - 1, a, c, b)        move(1, a, b, c)        move(n - 1, b, a, c)move(3, 'A', 'B', 'C')print(list)test = ['A-->C', 'A-->B', 'C-->B', 'A-->C', 'B-->A', 'B-->C', 'A-->C']if list==test:    print('测试成功!')else:    print('测试失败!')

  • 1

Reply