Example #1
0
        public static void TestSudokuSolver()
        {
            int[,] grid = new int[, ]
            {
                { 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 7, 9, 6, 0, 0 },
                { 2, 9, 3, 0, 5, 6, 0, 0, 0 },
                { 4, 0, 0, 5, 0, 2, 0, 0, 0 },
                { 3, 8, 1, 4, 0, 0, 5, 0, 0 },
                { 0, 5, 2, 0, 1, 0, 0, 9, 0 },
                { 9, 0, 0, 0, 3, 0, 0, 0, 0 },
                { 0, 0, 5, 0, 0, 0, 0, 0, 0 },
                { 0, 6, 0, 0, 0, 8, 0, 0, 7 }
            };
            Sudoku sk = new Sudoku(grid);

            Console.WriteLine("Sudoku problem");
            MatrixProblemHelper.PrintMatrix(sk.Grid);
            bool IsSudokuSolved = sk.SolveSudoku();

            if (IsSudokuSolved)
            {
                Console.WriteLine("Sudoku solution");
                MatrixProblemHelper.PrintMatrix(sk.Grid);
            }
            else
            {
                Console.WriteLine("Sudoku cannot be solved");
            }
        }
Example #2
0
        public static void TestKWayMerge()
        {
            KWayMerge merge = new KWayMerge();

            int[,] mat = new int[, ]
            {
                { 2, 4, 6, 7, 90 },
                { 3, 4, 66, 77, 88 },
                { 55, 65, 88, 90, 101 },
                { 1, 2, 3, 4, 5 }
            };
            Console.WriteLine("the input matrix is as shown below");
            MatrixProblemHelper.PrintMatrix(mat);
            Console.WriteLine("The sorted array is as shown below");
            ArrayHelper.PrintArray(merge.DoKWayMerge(mat));
        }