문제

문제 풀이
using System;
using System.Collections.Generic;
public class Solution
{
public int[,] solution(int n)
{
List<int[]> resultList = new List<int[]>();
Hanoi(n, 1, 3, 2, resultList);
int[,] result = new int[resultList.Count, 2];
for (int i = 0; i < resultList.Count; i++)
{
result[i, 0] = resultList[i][0];
result[i, 1] = resultList[i][1];
}
return result;
}
public void Hanoi(int n, int from, int to, int aux, List<int[]> resultList)
{
if (n == 1)
{
resultList.Add(new int[] { from, to });
return;
}
Hanoi(n - 1, from, aux, to, resultList);
resultList.Add(new int[] { from, to });
Hanoi(n - 1, aux, to, from, resultList);
}
}