Ejemplo n.º 1
0
        private void Run()
        {
            Inputs = new int[Core.Sudoku.SIZE, Core.Sudoku.SIZE];

            for (int y = 0; y < Core.Sudoku.SIZE; y++)
            {
                System.Console.Out.WriteLine($"Enter line {y + 1}, followed by enter key");
                for (int x = 0; x < Core.Sudoku.SIZE; x++)
                {
                    while (true)
                    {
                        int key    = System.Console.Read();
                        var number = key - 48;
                        if (number >= 0 && number <= 9)
                        {
                            Inputs[x, y] = number;
                            break;
                        }
                    }
                }
            }

            // var transposedInput = new int[Core.Sudoku.SIZE, Core.Sudoku.SIZE];
            // for (var i = 0; i < Core.Sudoku.SIZE; i++)
            // {
            //     for (var j = 0; j < Core.Sudoku.SIZE; j++)
            //     {
            //         transposedInput[i, j] = Inputs[j, i];
            //     }
            // }

            for (int y = 0; y < 9; y++)
            {
                for (int x = 0; x < 9; x++)
                {
                    System.Console.Out.Write($"{Inputs[x, y]}".PadRight(10, ' '));
                }

                System.Console.Out.WriteLine();
            }

            _sudoku = new Core.Sudoku(this);
            _sudoku.Solve();
        }
Ejemplo n.º 2
0
 private void btnSolve_Click(object sender, System.EventArgs e)
 {
     txtStatus.Text = string.Empty;
     _sudoku        = new Core.Sudoku(this);
     _sudoku.Solve();
 }