1. 阶乘函数
1 若n=0
Fact(n) = n*Fact(n-) 若n〉0
实现:
using System;
using System.Text;
namespace DataStructure
{
/// <summary>
///
/// </summary>
public class Recursion
{
/// <summary>
/// 阶乘
/// </summary>
/// <param name="n"></param>
/// <returns></returns>
public static int fact(int n)
{
if (n == 0)
return 1;
else
return n*fact(n-1);
}
}
}
测试:
using System;
using System.Text;
using DataStructure;
namespace DataStructureClient
{
class Program
{
static void Main(string[] args)
{
callFact();
Console.ReadLine();
}
static void callFact()
{
int result = Recursion.fact(4);
Console.WriteLine(result);
}
}
}
结果
24
2. 2阶Fibonacci数列
0 若n=0
Fib(n)= 1 若n=1
Fib(n-1)+Fib(n-2) 其他情况
实现:
using System;
using System.Text;
namespace DataStructure
{
/// <summary>
///
/// </summary>
public class Recursion
{
/// <summary>
/// 2阶Fibonacci数列
/// </summary>
/// <param name="n"></param>
/// <returns></returns>
public static int fibonacci(int n)
{
switch (n)
{
case 0:
return 0;
case 1:
return 1;
default:
return fibonacci(n - 1) + fibonacci(n - 2);
}
}
}
}
测试
using System;
using System.Text;
using DataStructure;
namespace DataStructureClient
{
class Program
{
static void Main(string[] args)
{
callFibonacci();
Console.ReadLine();
}
static void callFibonacci()
{
int result = Recursion.fibonacci(10);
Console.WriteLine(result);
}
}
}
结果
55
3. 汉诺塔
当n=1时,将编号为1的圆盘从塔座X直接移到塔座Z上;
当n>1时,利用塔座Y作为辅助塔座,将压在编号为n的圆盘之上的n-1个圆盘从塔座X移到塔座Y上,然后
将n从塔座X移到塔座Z上;之后再将塔座Y上的n-1个圆盘移到Z上。
实现:
using System;
using System.IO;
using System.Text;
namespace DataStructure
{
/// <summary>
///
/// </summary>
public class Recursion
{
private static List list=new ArrayList();
/// <summary>
/// hanoi tower
/// </summary>
/// <param name="n">n个圆盘</param>
/// <param name="x">出发塔座</param>
/// <param name="y">辅助塔座</param>
/// <param name="z">目的塔座</param>
public static void hanoi(int n, char x, char y, char z)
{
if (n == 1)
move(x, 1, z);
else
{
hanoi(n - 1, x, z, y); //将X上编号为1至n-1的圆盘移到Y上,Z为辅助塔座
move(x, n, z); //将编号为n的圆盘从X移到Z
hanoi(n - 1, y, x, z); //将Y上编号从1至n-1的圆盘移到Z上,X为辅助塔座
}
}
private static void move(char x, int n, char z)
{
list.add("move " + n + " from " + x + " to " + z);
Console.WriteLine("move " + n + " from " + x + " to " + z);
}
/// <summary>
/// save to file
/// </summary>
public static void save()
{
// Create an instance of StreamWriter to write text to a file.
// The using statement also closes the StreamWriter.
using (StreamWriter sw = new StreamWriter("Hanoi.txt"))
{
// Add some text to the file.
for(int i=0;i<list.length();i++)
sw.WriteLine(list.get(i));
}
}
}
}
测试
using System;
using System.Text;
using DataStructure;
namespace DataStructureClient
{
class Program
{
static void Main(string[] args)
{
callHanoi();
Console.ReadLine();
}
static void callHanoi()
{
Recursion.hanoi(10, 'x', 'y', 'z');
Recursion.save();
}
}
}
结果:
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 3 from x to y
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 4 from x to z
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 3 from y to z
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 5 from x to y
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 3 from z to x
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 4 from z to y
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 3 from x to y
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 6 from x to z
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 3 from y to z
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 4 from y to x
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 3 from z to x
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 5 from y to z
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 3 from x to y
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 4 from x to z
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 3 from y to z
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 7 from x to y
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 3 from z to x
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 4 from z to y
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 3 from x to y
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 5 from z to x
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 3 from y to z
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 4 from y to x
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 3 from z to x
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 6 from z to y
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 3 from x to y
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 4 from x to z
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 3 from y to z
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 5 from x to y
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 3 from z to x
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 4 from z to y
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 3 from x to y
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 8 from x to z
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 3 from y to z
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 4 from y to x
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 3 from z to x
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 5 from y to z
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 3 from x to y
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 4 from x to z
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 3 from y to z
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 6 from y to x
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 3 from z to x
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 4 from z to y
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 3 from x to y
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 5 from z to x
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 3 from y to z
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 4 from y to x
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 3 from z to x
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 7 from y to z
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 3 from x to y
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 4 from x to z
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 3 from y to z
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 5 from x to y
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 3 from z to x
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 4 from z to y
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 3 from x to y
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 6 from x to z
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 3 from y to z
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 4 from y to x
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 3 from z to x
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 5 from y to z
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 3 from x to y
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 4 from x to z
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 3 from y to z
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 9 from x to y
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 3 from z to x
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 4 from z to y
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 3 from x to y
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 5 from z to x
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 3 from y to z
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 4 from y to x
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 3 from z to x
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 6 from z to y
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 3 from x to y
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 4 from x to z
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 3 from y to z
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 5 from x to y
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 3 from z to x
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 4 from z to y
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 3 from x to y
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 7 from z to x
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 3 from y to z
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 4 from y to x
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 3 from z to x
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 5 from y to z
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 3 from x to y
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 4 from x to z
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 3 from y to z
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 6 from y to x
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 3 from z to x
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 4 from z to y
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 3 from x to y
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 5 from z to x
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 3 from y to z
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 4 from y to x
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 3 from z to x
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 8 from z to y
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 3 from x to y
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 4 from x to z
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 3 from y to z
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 5 from x to y
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 3 from z to x
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 4 from z to y
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 3 from x to y
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 6 from x to z
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 3 from y to z
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 4 from y to x
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 3 from z to x
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 5 from y to z
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 3 from x to y
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 4 from x to z
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 3 from y to z
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 7 from x to y
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 3 from z to x
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 4 from z to y
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 3 from x to y
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 5 from z to x
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 3 from y to z
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 4 from y to x
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 3 from z to x
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 6 from z to y
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 3 from x to y
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 4 from x to z
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 3 from y to z
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 5 from x to y
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 3 from z to x
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 4 from z to y
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 3 from x to y
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 10 from x to z
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 3 from y to z
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 4 from y to x
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 3 from z to x
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 5 from y to z
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 3 from x to y
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 4 from x to z
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 3 from y to z
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 6 from y to x
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 3 from z to x
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 4 from z to y
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 3 from x to y
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 5 from z to x
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 3 from y to z
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 4 from y to x
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 3 from z to x
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 7 from y to z
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 3 from x to y
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 4 from x to z
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 3 from y to z
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 5 from x to y
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 3 from z to x
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 4 from z to y
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 3 from x to y
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 6 from x to z
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 3 from y to z
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 4 from y to x
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 3 from z to x
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 5 from y to z
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 3 from x to y
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 4 from x to z
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 3 from y to z
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 8 from y to x
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 3 from z to x
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 4 from z to y
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 3 from x to y
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 5 from z to x
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 3 from y to z
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 4 from y to x
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 3 from z to x
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 6 from z to y
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 3 from x to y
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 4 from x to z
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 3 from y to z
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 5 from x to y
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 3 from z to x
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 4 from z to y
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 3 from x to y
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 7 from z to x
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 3 from y to z
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 4 from y to x
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 3 from z to x
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 5 from y to z
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 3 from x to y
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 4 from x to z
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 3 from y to z
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 6 from y to x
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 3 from z to x
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 4 from z to y
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 3 from x to y
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 5 from z to x
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 3 from y to z
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 4 from y to x
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 3 from z to x
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 9 from y to z
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 3 from x to y
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 4 from x to z
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 3 from y to z
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 5 from x to y
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 3 from z to x
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 4 from z to y
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 3 from x to y
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 6 from x to z
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 3 from y to z
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 4 from y to x
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 3 from z to x
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 5 from y to z
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 3 from x to y
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 4 from x to z
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 3 from y to z
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 7 from x to y
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 3 from z to x
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 4 from z to y
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 3 from x to y
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 5 from z to x
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 3 from y to z
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 4 from y to x
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 3 from z to x
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 6 from z to y
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 3 from x to y
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 4 from x to z
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 3 from y to z
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 5 from x to y
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 3 from z to x
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 4 from z to y
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 3 from x to y
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 8 from x to z
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 3 from y to z
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 4 from y to x
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 3 from z to x
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 5 from y to z
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 3 from x to y
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 4 from x to z
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 3 from y to z
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 6 from y to x
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 3 from z to x
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 4 from z to y
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 3 from x to y
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 5 from z to x
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 3 from y to z
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 4 from y to x
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 3 from z to x
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 7 from y to z
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 3 from x to y
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 4 from x to z
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 3 from y to z
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 5 from x to y
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 3 from z to x
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 4 from z to y
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 3 from x to y
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 6 from x to z
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 3 from y to z
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 4 from y to x
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 3 from z to x
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 5 from y to z
move 1 from x to y
move 2 from x to z
move 1 from y to z
move 3 from x to y
move 1 from z to x
move 2 from z to y
move 1 from x to y
move 4 from x to z
move 1 from y to z
move 2 from y to x
move 1 from z to x
move 3 from y to z
move 1 from x to y
move 2 from x to z
move 1 from y to z