κ°λ°/π€ μκ³ λ¦¬μ¦
baekjoon. 11729 νλ Έμ΄ ν μ΄λ μμ [Silver I][python]
ttoance
2023. 7. 12. 12:51
λ¬Έμ λ§ν¬ : https://www.acmicpc.net/problem/11729
n = int(input())
count = 0
startList = []
destList = []
def hanoi(n, start, dest, sub):
global count
if n == 1:
count += 1
startList.append(start)
destList.append(dest)
return
hanoi(n - 1, start, sub, dest)
count += 1
startList.append(start)
destList.append(dest)
hanoi(n - 1, sub, dest, start)
hanoi(n, 1, 3, 2)
print(count)
for i in range(count):
print(startList[i], destList[i])
νΉμ results.append(tuple([start, dest])) ν΅ν΄μ νλμ 리μ€νΈμ μ μ₯ν μ μλ€.
μ°Έκ³ μ ν¬λΈ >> https://www.youtube.com/watch?v=FYCGV6F1NuY
λ°μν