2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Pythonでハノイの塔を動かしてみた

Posted at

実行環境

  • Raspberry pi
  • Raspbian
  • Python 2.7

ソースコード

hanoi.py

   def hanoi(n, via, to, start):
  
           if n > 0:
                   hanoi(n-1, to, via, start)
                   print "%d %d %d" % (n, start, via)
                   hanoi(n-1, via, start, to)
  
  

最後に

Pythonの書き方を把握しない状態で書いたので、いろいろ変な部分があると思います。
とりあえず自分用のメモとしてプログラムを残します。

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?