public int[,] GenerateSudokuBoardWithDifficultySetting(int[,] board, DifficultySetting difficultySetting) { var updatedBoard = board; //setup the board info boardInfo = CommonMethods.GetSudokuBoardSize(board); //setup each difficulty situation that is required foreach (var difficultySituation in difficultySetting.DifficultySituations) { updatedBoard = AddDifficultySitiuationToBoard(updatedBoard, difficultySituation); } return(updatedBoard); }
internal List <int[, ]> SolveSudokuBoard(int[,] startingBoard) { //setup the board size boardInfo = CommonMethods.GetSudokuBoardSize(startingBoard); //get all the unfilled locations var unfilledLocations = GetUnfilledBoardLocations(startingBoard); var solvedBoards = new List <int[, ]>(); //start populating the solution tree AddLocationsSolutionsToList(unfilledLocations, startingBoard, solvedBoards, 0); return(solvedBoards); }
public static SudokuBoardInfo GetSudokuBoardSize(int[,] board) { var boardInfo = new SudokuBoardInfo(); //get the board size boardInfo.BoardSize = board.GetLength(0); //get the inner board size var boardSizeSquerRoot = Math.Sqrt(board.GetLength(0)); boardInfo.InnerBoardSize = (int)boardSizeSquerRoot; //check to see if the board is a proper sudoku board (row number == coloumn number) if (board.GetLength(0) != board.GetLength(1) || ((int)(boardSizeSquerRoot * 10) != boardInfo.InnerBoardSize * 10)) { throw new Exception("The board is not a proper sudoku board"); } return(boardInfo); }