private bool IsValidWholeGrid(int[] grid) { var rows = _sectionCutter.GetAllRows(grid); var columns = _sectionCutter.GetAllColumns(grid); var squares = _sectionCutter.GetAllSquares(grid); return(ContainsNoDuplicates(squares) && ContainsNoDuplicates(rows) && ContainsNoDuplicates(columns)); }
private int[][] GetPossibleNumbersInGrid(int[] gridIntArray) { var possibilities = new int[81][]; int indexInGrid = 0; var rawRows = _sectionCutter.GetAllRows(gridIntArray); var allRows = rawRows.ToJaggedArray(); var allColumns = _sectionCutter.GetAllColumns(gridIntArray).ToJaggedArray(); var allSquares = _sectionCutter.GetAllSquares(gridIntArray).ToJaggedArray(); for (int i = 0; i < 81; i++) { var number = gridIntArray[i]; if (number == 0) { var possibleNumbers = Helper.ZeroToNineArray.AsEnumerable(); var position = _positionCalculator.GetPosition(indexInGrid); var currentRow = allRows[position[0]]; var currentColumn = allColumns[position[1]]; var currentSquare = allSquares[position[2]]; var itemsToRemove = currentRow.Union(currentColumn).Union(currentSquare); possibleNumbers = possibleNumbers.Except(itemsToRemove); possibilities[i] = possibleNumbers.ToArray(); } else { possibilities[i] = new int[1] { gridIntArray[indexInGrid] }; } ++indexInGrid; } return(possibilities); }