Skip to content

Commit

Permalink
[#12] Feat: Add 하노이 탑
Browse files Browse the repository at this point in the history
  • Loading branch information
letsjo committed Apr 10, 2023
1 parent c3ccb73 commit 20b364b
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions 1914.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# 하노이 탑

def move(n, start, target):
if n > 1:
move(n-1, start, 6-start-target)

print(start, target)

if n > 1:
move(n-1, 6-start-target, target)


N = int(input())

print(2**N-1)

if (N <= 20):
move(N, 1, 3)

0 comments on commit 20b364b

Please sign in to comment.