public DifficultyType CheckSudokuDifficulty(SudokuCell[,] inputSudoku) { InitializeSudoku(inputSudoku); var easySudoku = new EasySudokuTechniques(this); var mediumSudoku = new MediumSudokuTechniques(this); var hardSudoku = new HardSudokuTechniques(this); counter = GetTheCountOfClues(); var sudokuDifficulty = DifficultyType.Easy; while (true) { if (counter == 81) { break; } if (!easySudoku.UseAllEasyTechniques()) { sudokuDifficulty = DifficultyType.Medium; if (!mediumSudoku.UseNakedPairTechnique()) { if (!mediumSudoku.UseNakedPairInBoxTechnique()) { if (!mediumSudoku.UseCandidateLinesTechnique()) { if (!mediumSudoku.UseX_WingTechnique()) { if (!mediumSudoku.UseUniqueRectangleTechnique()) { sudokuDifficulty = DifficultyType.Hard; if (!hardSudoku.UseNishioTechnique(easySudoku, mediumSudoku)) { sudokuDifficulty = DifficultyType.VeryHard; return(sudokuDifficulty); } } } } } } } } return(sudokuDifficulty); }
public SudokuCell[,] SolveSudoku(SudokuCell[,] inputSudoku) { InitializeSudoku(inputSudoku); var easySudoku = new EasySudokuTechniques(this); var mediumSudoku = new MediumSudokuTechniques(this); var hardSudoku = new HardSudokuTechniques(this); counter = GetTheCountOfClues(); while (true) { if (counter == 81) { break; } if (!easySudoku.UseAllEasyTechniques()) { if (!mediumSudoku.UseNakedPairTechnique()) { if (!mediumSudoku.UseNakedPairInBoxTechnique()) { if (!mediumSudoku.UseCandidateLinesTechnique()) { if (!mediumSudoku.UseX_WingTechnique()) { if (!mediumSudoku.UseUniqueRectangleTechnique()) { if (!hardSudoku.SolveSudoku(easySudoku, mediumSudoku)) { //Should NEVER enter this if statement! throw new ArgumentException("Problem with the sudoku!!!"); } } } } } } } } return(this.sudoku); }