/* Author: Hannes du Plooy */ /* Date: 20 Sep 2016 */ /* Objective: To solve the towers of hanoi with number of discs provided in the arguments to calling the program */ using System; using System.IO; namespace HanoiNS { public class HanoiClass { static void Hanoi(int source,int dest,int other,int discs) { if (discs > 0) { Hanoi(source,other,dest,discs-1); Console.WriteLine("Move " + source + " to " + dest); Hanoi(other,dest,source,discs-1); } } static void Main(string[] args) { if (args.Length < 1) { Console.WriteLine("Please provide number of discs!"); } else { Hanoi(0,2,1,int.Parse(args[0])); } } } }