/// <summary> /// Fills the leftInts array with all blocks as far up as possible /// </summary> /// <param name="column">column index</param> /// <param name="leftInts">array to edit</param> /// <param name="clueIndex">clue to use for this step in recursion</param> /// <param name="colPos">current fill position of array. (used for recursion)</param> /// <returns>false if a contradiction is encountered</returns> private bool ColLeft(int column, int[] leftInts, int clueIndex, int colPos) { int clue = _ng.GetColumnNum(column, clueIndex); if (clue == 0) { for (int i = colPos; i < _ng.Height; i++) { if (_ng.IsTrue(i, column)) { return(false); } leftInts[i] = clueIndex * 2 - 1; } return(true); } int localPos = colPos; bool posChanged; while (true) { posChanged = false; for (int i = localPos; i < localPos + clue; i++) { if (i >= leftInts.Length) { return(false); } if (_ng.IsFalse(i, column)) { for (int j = localPos; j <= i; j++) { if (_ng.IsTrue(j, column)) { return(false); } leftInts[j] = clueIndex * 2 - 1; } localPos = i + 1; posChanged = true; break; } leftInts[i] = clueIndex * 2; } if (posChanged) { continue; } if (localPos + clue >= leftInts.Length) { return(true); } if (!_ng.IsTrue(localPos + clue, column)) { leftInts[localPos + clue] = clueIndex * 2 + 1; if (ColLeft(column, leftInts, clueIndex + 1, localPos + clue + 1)) { return(true); } if (_ng.IsTrue(localPos, column)) { return(false); } } leftInts[localPos] = clueIndex * 2 - 1; localPos++; } }