문제 출처
풀이
def hanoi(num, _from, _by, _to):
if num == 1:
res.append((_from, _to))
return
else:
hanoi(num-1, _from, _to, _by)
res.append((_from, _to))
hanoi(num-1, _by, _from, _to)
N = int(input())
res = []
hanoi(N, 1, 2, 3)
print(len(res))
for i, j in res:
print(i, j)
'백준' 카테고리의 다른 글
[python] 13717. 포켓몬 GO (0) | 2019.10.28 |
---|---|
[python] 2312. 수 복원하기 (0) | 2019.10.27 |
[python] 13900. 순서쌍의 곱의 합 (0) | 2019.10.22 |
[python] 15953. 상금 헌터 (0) | 2019.10.22 |
[python] 2630. 색종이 만들기 (0) | 2019.10.21 |