我的代码有什么问题?添加“否”后失败代码中采取的步骤

问题描述

请查看其他块结束的最后一行

#defining function
def toh(N,fromm=1,to=3,aux=2):

    if N == 1:
        print('move disk',N,'from rod',fromm,'to rod',to)
        return


    else:
        toh(N - 1,aux,to)
        print('move disk',to)
        toh(N - 1,to,fromm)

    # Number of steps taken
    print(2**N - 1)


toh(N=1)

它适用于所有测试用例,但在向代码添加了许多步骤后,它却无法运行。

我希望我的代码打印输出的最后一行上执行的步骤数

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)