Logo Search packages:      
Sourcecode: vdr-plugin-sudoku version File versions  Download package

void Puzzle::compute_numbers ( Pos  pos  )  [private]

Compute all possible numbers for this cell.

Definition at line 237 of file puzzle.cpp.

References Sudoku::Pos::col(), Sudoku::DIM, Sudoku::Pos::reg(), and Sudoku::Pos::row().

Referenced by reset(), and set().

{
  assert(pos <= Pos::last());
  unsigned int i;

  // Fill list with all numbers.
  for (i = 1; i <= DIM; ++i)
    numbers[pos][i] = true;

  // Disable numbers found in row, column or region.
  for (Pos p = Pos::first(); p <= Pos::last(); p = p.next())
    if (p != pos &&
        (p.col() == pos.col() || p.row() == pos.row() || p.reg() == pos.reg()))
      numbers[pos][get(p)] = false;

  // Count the possible numbers.
  count[pos] = 0;
  for (i = 1; i <= DIM; ++i)
    if (numbers[pos][i])
      ++count[pos];

  // 0 is always possible.
  numbers[pos][0] = true;
}


Generated by  Doxygen 1.6.0   Back to index