public bool VerifyColumn(int columnNumber) { CellCoordinate cell = new CellCoordinate(0, columnNumber); Del handler = cell.MoveToNextCellInColumn; return(Verify(handler)); }
public bool FillBoard(CellCoordinate cell) { if (IsCellEmpty(cell)) { iterations++; foreach (int value in Enumerable.Range(1, 9)) { if (!TrySetCell(cell, value)) { continue; } Print(); if (FillBoard(cell)) { return(true); } } ClearCell(cell); return(false); } if (cell.MoveToNextCellInGrid()) { return(FillBoard(cell)); } return(true); }
public bool VerifyRow(int rowNumber) { CellCoordinate cell = new CellCoordinate(rowNumber, 0); Del handler = cell.MoveToNextCellInRow; return(Verify(handler)); }
public bool VerifyBlock(int blockNumber) { int rowOffset = (blockNumber / 3) * 3; int columnOffset = (blockNumber % 3) * 3; CellCoordinate cell = new CellCoordinate(rowOffset, columnOffset); Del handler = cell.MoveToNextCellInBlock; return(Verify(handler)); }
public void DeleteRandomCell() { CellCoordinate cell = new CellCoordinate(); do { cell.Randomize(); } while (IsCellEmpty(cell)); ClearCell(cell); }
public bool IncreaseCellValue(CellCoordinate cell) { if (board[cell.row, cell.column] < 9) { board[cell.row, cell.column]++; return(true); } board[cell.row, cell.column] = 0; return(false); }
public bool TrySetCell(CellCoordinate cell, int value) { SetCell(cell, value); return(VerifyBoard()); }
public bool IsCellEmpty(CellCoordinate cell) { return(board[cell.row, cell.column] == 0); }
public void ClearCell(CellCoordinate cell) { board[cell.row, cell.column] = 0; }
public int GetCell(CellCoordinate cell) { return(board[cell.row, cell.column]); }
public void SetCell(CellCoordinate cell, int value) { board[cell.row, cell.column] = value; }
public void Solve() { CellCoordinate cell = new CellCoordinate(); FillBoard(cell); }