public static List <CellGroup> GetOpenCellGroups(List <int> indices, SudokuPuzzle puzzle, UnitType uType) { CellGroup[] cellGroups = new CellGroup[3]; switch (uType) { case UnitType.row: cellGroups[0] = puzzle.rowCollection[indices[0] - 1]; cellGroups[1] = puzzle.rowCollection[indices[1] - 1]; cellGroups[2] = puzzle.rowCollection[indices[2] - 1]; break; case UnitType.column: cellGroups[0] = puzzle.colCollection[indices[0] - 1]; cellGroups[1] = puzzle.colCollection[indices[1] - 1]; cellGroups[2] = puzzle.colCollection[indices[2] - 1]; break; case UnitType.subgrid: cellGroups[0] = puzzle.sgCollection[indices[0] - 1]; cellGroups[1] = puzzle.sgCollection[indices[1] - 1]; cellGroups[2] = puzzle.sgCollection[indices[2] - 1]; break; } var openGroups = from CellGroup cg in cellGroups where !IsGroupClosed(cg) select cg; if (openGroups != null) { return(openGroups.ToList()); } return(null); }
public bool MemberValsFitDomain(CellGroup ip) { HashSet <int> memSet = new HashSet <int>(ip.GetGroupFills()); HashSet <int> sudoHash = new HashSet <int>(SudokuPuzzle.sudokuDomain); return(memSet.SetEquals(sudoHash)); }
public int intersectValue; //replace with single int value public SGUnitIntersectKey(CellGroup cg, List <SudokuCell> intercells, List <SudokuCell> prohibitCells, int intersectingInt) { intersectCells = intercells; elimCells = prohibitCells; intersectValue = intersectingInt; subgrid = cg; }
public void ClearPuzzle() { discardedValuesTable.Clear(); cellBoard = new Board(); rowCollection = new CellGroup[9]; colCollection = new CellGroup[9]; sgCollection = new CellGroup[9]; isSolved = false; //domainFreqCounter.Clear(); }
public static bool IsGroupClosed(CellGroup cellGroup) { if (cellGroup.GetOpenCellCount() == 0) { return(true); } else { return(false); } }
public void InitializeCellGroups() { for (int i = 0; i < 9; i++) { CellGroup freshRow = new CellGroup(UnitType.row); rowCollection[i] = freshRow; rowCollection[i].SetIndex(i + 1); CellGroup freshColumn = new CellGroup(UnitType.column); colCollection[i] = freshColumn; colCollection[i].SetIndex(i + 1); CellGroup freshSubgrid = new CellGroup(UnitType.subgrid); sgCollection[i] = freshSubgrid; sgCollection[i].SetIndex(i + 1); } }
public void InitializeCellGroups() { for (int h = 0; h < 9; h++) { rowList[h] = new CellGroup(UnitType.row); columnList[h] = new CellGroup(UnitType.column); subgridList[h] = new CellGroup(UnitType.subgrid); } for (int i = 0; i < 9; i++) { rowList[i] = new CellGroup(UnitType.row); rowList[i].SetIndex(i + 1); columnList[i] = new CellGroup(UnitType.column); columnList[i].SetIndex(i + 1); subgridList[i] = new CellGroup(UnitType.subgrid); subgridList[i].SetIndex(i + 1); } }
public List <int> GetSubgridIndices(CellGroup cg, int n) { if (cg.GroupType == UnitType.subgrid) { return new List <int>() { cg.Index } } ; List <SudokuCell> cellsWithN = cg.GetCellsWithPossibility(n); //first, get the list of cells within the cell group that has n as a possibility if (cellsWithN != null) { var sgInds = cellsWithN.Select(x => x.sgNumber); return(sgInds.ToList()); } return(null); }
//public IEnumerable<CellPossAssociation> GetCellPossibilityAssociations(CellGroup cell_gr) { //} public void MapCellAssociations(CellGroup c_gr) { }
public bool IsGroupWeightCorrect(CellGroup ip) { return(ip.GetGroupFills().Sum() == 45); }
public bool AllMembersFilled(CellGroup ip) { return(ip.GetOpenCellCount() == 0); }