20200421 3문제

2447
11729
2447_loop (add  뭔가 2447이 이상함 다시 풀어야겠음)
This commit is contained in:
2020-04-21 12:52:50 +09:00
parent 7c20c34a76
commit 1e1a687355
5 changed files with 34 additions and 51 deletions

View File

@@ -0,0 +1,14 @@
N = int(input())
def move(f, t):
print(f, t)
def hanoi(n, f, b, t):
if n == 1:
move(f, t)
else:
hanoi(n-1, f, t, b)
move(f, t)
hanoi(n-1, b, f, t)
print(2**N-1)
hanoi(N, 1,2,3)

View File

@@ -0,0 +1,19 @@
N = int(input())
A = ([" "] * N + ["\n"]) * N
def B(n, x, y):
global A
if n == 0:
A[(N+1)*y+x] = "*"
return
c = n//3
for i in range(3):
for j in range(3):
if i == 1 and j == 1:
continue
B(c, x+c*i, y+c*j)
B(N, 0, 0)
for i in A:
print(i, end="")