private static bool CheckSeveralMissingColumn(GridSquareScript selection, GridSquareScript[] gridSquares) { int col = GridMaths.ColumnForSquare(selection.Index); GridSquareScript[] emptyColSquares = EmptyGridsAtIndexes(GridMaths.GridColumnIndices(col), gridSquares, selection); int[] emptyIndices = emptyColSquares.Select(x => x.Index).Distinct().ToArray(); int[] bigSquareIndices = emptyColSquares.Select(x => GridMaths.BigSquareForSquare(x.Index)).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.GridColumnInSquare(col, box)).ToArray(); if (checks.Length > 0) { usableSquares.AddRange(checks); } } } if (usableSquares.Count > 0) { return(usableSquares.All(x => DoesRowContainNumber(GridMaths.RowForSquare(x), selection, gridSquares))); } return(true); }
private static bool DoesColumnInSquareHaveSpace(int col, int square, int index, GridSquareScript[] gridSquares) { GridSquareScript[] colInSquareSquares = GridsAtIndexes(GridMaths.GridColumnInSquare(col, square), gridSquares); return(colInSquareSquares.Any(x => x.Number == 0 && !x.IsTarget)); //x.Index != index); }