1 parent 69ad8d4 commit 3902c53Copy full SHA for 3902c53
1 file changed
이티예원/11729_하노이 탑.py
@@ -0,0 +1,16 @@
1
+n = int(input())
2
+
3
+def top(n, a, b, c):
4
5
+ if n == 1:
6
+ print(a, c)
7
8
+ else:
9
+ top(n-1, a, c, b)
10
11
+ top(n-1, b, a, c)
12
13
+sum = 2 ** n -1
14
+print(sum)
15
16
+top(n, 1, 2, 3)
0 commit comments