private static bool CheckSeveralMissingRow(GridSquareScript selection, GridSquareScript[] gridSquares) { int row = GridMaths.RowForSquare(selection.Index); GridSquareScript[] emptyRowSquares = EmptyGridsAtIndexes(GridMaths.GridRowIndices(row), gridSquares, selection); int[] emptyIndices = emptyRowSquares.Select(x => x.Index).Distinct().ToArray(); int[] bigSquareIndices = emptyIndices.Select(x => GridMaths.BigSquareForSquare(x)).Distinct().ToArray(); List <int> usableSquares = new List <int>(); for (int i = 0; i < bigSquareIndices.Length; i++) { int box = bigSquareIndices[i]; if (!DoesBigSquareContainNumber(box, selection, gridSquares)) { int[] checks = emptyIndices.Intersect(GridMaths.GridRowInSquare(row, box)).ToArray(); if (checks.Length > 0) { usableSquares.AddRange(checks); } } } if (usableSquares.Count > 0) { return(usableSquares.All(x => DoesColumnContainNumber(GridMaths.ColumnForSquare(x), selection, gridSquares))); } return(true); }
private static bool DoesRowInSquareHaveSpace(int row, int square, int index, GridSquareScript[] gridSquares) { GridSquareScript[] rowInSquareSquares = GridsAtIndexes(GridMaths.GridRowInSquare(row, square), gridSquares); return(rowInSquareSquares.Any(x => x.Number == 0 && !x.IsTarget)); //x.Index != index); }