コード例 #1
0
        public void SolveGuessing(SudokuModel sudokuModel)
        {
            SolveLogical(sudokuModel);

            SudokuBackupModel backup = new SudokuBackupModel
            {
                BackupCells = SubComponents.CopyArray(sudokuModel.Cells)
            };

            while (!SubComponents.CheckIfSolved(sudokuModel.Cells))
            {
                while (!SubComponents.CheckIfStuck(sudokuModel.Cells))
                {
                    sudokuModel.Cells = SubComponents.GuessANumber(sudokuModel);
                    sudokuModel.Cells = SolveLogical(sudokuModel);
                    if (SubComponents.CheckIfSolved(sudokuModel.Cells))
                    {
                        return;
                    }
                }
                sudokuModel.Cells = SubComponents.CopyArray(backup.BackupCells);
            }
        }
コード例 #2
0
        public void SolveGuessing(SudokuModel sudokuModel)
        {
            PlaceNumbers(sudokuModel.Cells);

            SudokuBackupModel backup = new SudokuBackupModel
            {
                BackupCells = CopyArray(sudokuModel.Cells)
            };

            while (!CheckIfSolved(sudokuModel.Cells))
            {
                while (!CheckIfStuck(sudokuModel.Cells))
                {
                    sudokuModel.Cells = GuessANumber(sudokuModel);
                    //Program.PrintSudoku(sudokuModel.Cells);
                    sudokuModel.Cells = PlaceNumbers(sudokuModel.Cells);
                    if (CheckIfSolved(sudokuModel.Cells))
                    {
                        return;
                    }
                }
                sudokuModel.Cells = CopyArray(backup.BackupCells);
            }
        }