示例#1
0
		public static void Main (string[] args)
		{
			int[,] input = new int[9,9] {
				{7,2,0,0,3,9,0,0,6},
				{0,0,0,0,5,0,3,0,1},
				{0,0,0,0,0,7,0,0,5},
				{0,0,0,0,0,0,1,0,0},
				{9,0,6,0,0,0,0,0,2},
				{0,3,0,0,0,0,5,0,0},
				{3,7,0,0,0,4,8,0,0},
				{6,0,8,9,7,0,0,3,0},
				{5,0,0,0,0,0,0,0,0}
			};

//			int[,] input = new int[9,9] {
//				{7,2,5,1,3,9,4,8,6},
//				{4,6,9,2,5,8,3,7,1},
//				{1,8,3,4,6,7,9,2,5},
//				{8,4,7,5,9,2,1,6,3},
//				{9,5,6,3,8,1,7,4,2},
//				{2,3,1,7,4,6,5,9,8},
//				{3,7,2,6,1,4,8,5,9},
//				{6,1,8,9,7,5,2,3,4},
//				{5,9,4,8,2,3,6,1,7}
//			};


//			int[,] input = new int[4, 4] {
//				{ 0, 2, 0, 1 } ,
//				{ 1, 0, 0, 4 } ,
//				{ 0, 4, 1, 3 } ,
//				{ 3, 0, 4, 0 } 
//			};

			SudokuSolver ss = new SudokuSolver (input);
			ss.Print ();

			Console.WriteLine ("");
		}
示例#2
0
        public static void Main(string[] args)
        {
            int[,] input = new int[9,9] {
                {7,2,0,0,3,9,0,0,6},
                {0,0,0,0,5,0,3,0,1},
                {0,0,0,0,0,7,0,0,5},
                {0,0,0,0,0,0,1,0,0},
                {9,0,6,0,0,0,0,0,2},
                {0,3,0,0,0,0,5,0,0},
                {3,7,0,0,0,4,8,0,0},
                {6,0,8,9,7,0,0,3,0},
                {5,0,0,0,0,0,0,0,0}
            };

            //			int[,] input = new int[9,9] {
            //				{7,2,5,1,3,9,4,8,6},
            //				{4,6,9,2,5,8,3,7,1},
            //				{1,8,3,4,6,7,9,2,5},
            //				{8,4,7,5,9,2,1,6,3},
            //				{9,5,6,3,8,1,7,4,2},
            //				{2,3,1,7,4,6,5,9,8},
            //				{3,7,2,6,1,4,8,5,9},
            //				{6,1,8,9,7,5,2,3,4},
            //				{5,9,4,8,2,3,6,1,7}
            //			};

            //			int[,] input = new int[4, 4] {
            //				{ 0, 2, 0, 1 } ,
            //				{ 1, 0, 0, 4 } ,
            //				{ 0, 4, 1, 3 } ,
            //				{ 3, 0, 4, 0 }
            //			};

            SudokuSolver ss = new SudokuSolver (input);
            ss.Print ();

            Console.WriteLine ("");
        }
示例#3
0
        static void Main(string[] args)
        {
            var boardMaster = new SudokuSolver();

            //  var board = boardMaster.SetBoard();
            var board = boardMaster.ReadBoardFromFile();

            var result = boardMaster.Solve(board);

            foreach (var salution in result)
            {
                boardMaster.Print(salution);
                Console.WriteLine(new string('-', 17));
            }

            if (result.Count() > 1)
            {
                Console.WriteLine("Salutions count: " + result.Count());
            }
            else if (result.Count() == 0)
            {
                Console.WriteLine("No solution possible!");
            }
        }