[프로그래머스/파이썬] 하노이의 탑
나의 풀이 (시간 초과) def solution(n): c1 = [0, 1, 3, 2] c2 = [0, 2, 1, 3] dp = [[]] * n dp[0] = [[1,3]] for i in range(1, n): for x in dp[i - 1]: dp[i].append([c1[x[0]], c1[x[1]]]) dp[i].append([1, 3]) for x in dp[i - 1]: dp[i].append([c2[x[0]], c2[x[1]]]) return dp[-1] - 횟수로 이해하고 dp로 해결하고자 했다. 나의 풀이 (재귀) def hanoi(n, a, b, c): if n == 1: return [[a, c]] return hanoi(n - 1, a, c, b) + [[a, c]] + hanoi(..