public SudokuGame() { _sudoku = new Sudoku(showDifficultyDialogBox()); InitializeComponent(); AddSudoku(_sudoku); }
public bool CheckAnswer(Sudoku sudoku) { //Check for duplicates in row, column, and square var _sudoku = sudoku; var _board = _sudoku.sudokuBoard; int row = 0, column = 0; //Check Rows for (int i = 0; i < _board.Length; i++) { var rowGroups = _board[i].GroupBy(v => v); foreach (var number in rowGroups) { if (number.Count() > 1) { return(false); } } } //Check columns for (int i = 0; i < _board.Length; i++) { var columnGroup = GetColumnSudoku(_board, i); var columnGroups = columnGroup.GroupBy(v => v); foreach (var number in columnGroups) { if (number.Count() > 1) { return(false); } } } //Check grid while (row < 9) { while (column < 9) { var gridGroup = GetGridSudoku(_board, row, column); var gridGroups = gridGroup.GroupBy(v => v); foreach (var number in gridGroups) { if (number.Count() > 1) { return(false); } } column += 3; } row += 3; column = 0; } return(true); }
public Game() { sudoku = new Sudoku(); }