~cpp 
#include <iostream>

using namespace std;

int num(int val, int start, int end);

int main()
{
	cout << num(3, 1, 2) << endl;

	return 0;
}

int num(int val, int start, int end)
{
	
	if(val == 1)
	{
		cout << start << "->" << end << endl;

		return 1;
	}
	else
	{
		return num(val - 1, start, 6-start-end) + num(1,start,end) + num(val - 1, 6-start-end, end);
	}
}

Retrieved from http://wiki.zeropage.org/wiki.php/하노이탑/이재혁김상섭
last modified 2021-02-07 05:31:29