Skip to content

probabilityhill/hanoi-csharp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 

Repository files navigation

ハノイの塔(C#)

詳細 → Qiita記事
実行はこちら(入力は半角数字)

アルゴリズム

GOAL: move n disks from A to C

move n-1 disks from A to B -> 再帰
move disk n from A to C
move n-1 disks from B to C -> 再帰

Tower of hanoi

実行例(n=3)

How many disks? -> 3

move disk 1 from A to C.
move disk 2 from A to B.
move disk 1 from C to B.
move disk 3 from A to C.
move disk 1 from B to A.
move disk 2 from B to C.
move disk 1 from A to C.