加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
Python Program for Tower of Hanoi 414 Bytes
一键复制 编辑 原始数据 按行查看 历史
# Recursive Python function to solve the tower of hanoi
def TowerOfHanoi(n , source, destination, auxiliary):
if n==1:
print "Move disk 1 from source",source,"to destination",destination
return
TowerOfHanoi(n-1, source, auxiliary, destination)
print "Move disk",n,"from source",source,"to destination",destination
TowerOfHanoi(n-1, auxiliary, destination, source)
n = 4
TowerOfHanoi(n,'A','B','C')
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化