1번 자리에서 3번자리로 n개의 하노이 탑을 옮겨야 한다면
n이 1일 때 중단한다.
재귀를 풀 때는 중단 조건을 찾고, 전체 과정을 정형화해야 함.
# 11729
N = int(input())
move = []
def hanoi(level, start, mid, end):
if level == 1:
move.append((start, end))
return
hanoi(level - 1, start, end, mid)
move.append((start, end))
hanoi(level - 1, mid, start, end)
hanoi(N, 1, 2, 3)
print(len(move))
for i in move:
print(*i)
# 1914
N = int(input())
ans = 0
def hanoi(level, start, mid, end):
global ans
ans += 1
if level == 1:
print(start, end)
return
hanoi(level - 1, start, end, mid)
print(start, end)
hanoi(level - 1, mid, start, end)
print(2**N -1)
if N <= 20:
hanoi(N, 1, 2, 3)