public bool process(IBoardPortion p, Dictionary <Cell, Cell> processedInvalidCells) { uint currentCount = this.board.getValueCountInBoard(this.valToProcess); if (this.board.maxN == currentCount) { return(false); } Cell cellToAssign = null; if (p.getNumberPresence(valToProcess) == false) { var allFreeCells = p.getAllFreeCells(); for (int idx = 0; idx < allFreeCells.Count; ++idx) { var c = allFreeCells[idx]; if (processedInvalidCells.ContainsKey(c) == false) { if (c.partOfRow.getNumberPresence(valToProcess) == false && c.partOfCol.getNumberPresence(valToProcess) == false && c.partOfGrid.getNumberPresence(valToProcess) == false) { if (cellToAssign == null) { cellToAssign = c; } else { cellToAssign = null; break; } } else { processedInvalidCells[c] = c; } } } if (cellToAssign != null) { cellToAssign.setVal(valToProcess); return(true); } } return(false); }
public bool process(IBoardPortion p, Dictionary <Cell, Cell> processedInvalidCells) { bool valueSet = false; uint t = p.getRemainingCount(); if (t == 1) { var n = p.getNextMissingNumber(); var cell = p.getNextFreeCell(); if (cell != null) { cell.setVal(n); valueSet = true; } } return(valueSet); }