๋ฐ์ํ
๐ค๋ฌธ์ ํด๊ฒฐ
-
S2 | ์ฌ๊ท
ํ๋ ธ์ดํ - 1๋ฒ์ ์์นํ ์๋ฐ์ ๊ณ ๋๋ก 3๋ฒ์ผ๋ก ์ฎ๊ธฐ๋ ๊ฒ!! ์ฌ๊ท๋ฅผ ๋ฐฐ์ธ ๋ ๋จ๊ณจ ๋ฌธ์
๐ป์์ค ์ฝ๋
def hanoi(n, start, end, sub):
if n == 1:
# print(f'{start}=>{end}')
answer.append([start, end])
return
hanoi(n - 1, start, sub, end)
# print(f'{start}=>{end}')
answer.append([start, end])
hanoi(n - 1, sub, end, start)
N = int(input())
answer = []
hanoi(N, 1, 3, 2)
# ์ถ๋ ฅ
print(len(answer))
for i in answer:
print(*i)
๐๋ฌธ์ ํ์ธ
์ถ์ฒ: BACKJOON ONLINE JUDGE
๋ฐ์ํ
'Algorithm Problem > Python' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[python] ๋ฐฑ์ค - 1541. ์์ด๋ฒ๋ฆฐ ๊ดํธ (0) | 2020.10.08 |
---|---|
[python] ๋ฐฑ์ค - 2133. ํ์ผ ์ฑ์ฐ๊ธฐ (1) | 2020.10.07 |
[python] ๋ฐฑ์ค - 1182. ๋ถ๋ถ์์ด์ ํฉ (0) | 2020.10.05 |
[python] ๋ฐฑ์ค - 11055. ๊ฐ์ฅ ํฐ ์ฆ๊ฐ ๋ถ๋ถ ์์ด (0) | 2020.10.04 |
[python] ๋ฐฑ์ค - 11722. ๊ฐ์ฅ ๊ธด ๊ฐ์ํ๋ ๋ถ๋ถ ์์ด (0) | 2020.10.03 |