/// <summary> /// Generates a new <see cref="SudokuPuzzle"/> by filling it with numbers and then removing numbers according to <c><paramref name="difficulty"/></c>. /// </summary> /// <param name="size">The number of elements that the new <see cref="SudokuPuzzle"/> can store in each row, column and block.</param> /// <param name="difficulty">The difficulty associated with the <see cref="SudokuPuzzle"/>.</param> /// <returns>A new <see cref="SudokuPuzzle"/>.</returns> /// <exception cref="ArgumentException"><c><paramref name="size"/></c> is not a positive, square integer - or - <c><paramref name="difficulty"/></c> is equal to <see cref="SudokuDifficulty.None"/>.</exception> /// <exception cref="ArgumentOutOfRangeException"><c><paramref name="size"/></c> is less than or equal to 0 or greater than <see cref="SudokuPuzzle.MaximumSupportedSize"/>.</exception> public static SudokuPuzzle Generate(int size, SudokuDifficulty difficulty) { SudokuPuzzle sudoku = SudokuGenerator.AddNumbers(size, difficulty); SudokuGenerator.RemoveNumbers(sudoku); return(sudoku); }
/// <summary> /// Creates a new <see cref="SudokuPuzzle"/> and fills it with numbers. /// </summary> /// <param name="size">The number of elements that the new <see cref="SudokuPuzzle"/> can store in each row, column and block.</param> /// <param name="difficulty">The difficulty associated with the <see cref="SudokuPuzzle"/>.</param> /// <returns>A new <see cref="SudokuPuzzle"/> filled with numbers.</returns> /// <exception cref="ArgumentException"><c><paramref name="size"/></c> is not a positive, square integer - or - <c><paramref name="difficulty"/></c> is equal to <see cref="SudokuDifficulty.None"/>.</exception> /// <exception cref="ArgumentOutOfRangeException"><c><paramref name="size"/></c> is less than or equal to 0 or greater than <see cref="SudokuPuzzle.MaximumSupportedSize"/>.</exception> public static SudokuPuzzle AddNumbers(int size, SudokuDifficulty difficulty) { if (difficulty == SudokuDifficulty.None) { throw new ArgumentException(nameof(difficulty)); } SudokuPuzzle sudoku = new SudokuPuzzle(size, difficulty); SudokuGenerator.AddNumbers(sudoku); return(sudoku); }