All pastes #346197 Raw Edit

arthur

public cpp v1 · immutable
·published 2007-02-09 04:01 UTC
rendered paste body
#ifndef Sudoku_h_#define Sudoku_h_#include <vector>using namespace std;class Sudoku {public:  //  Construct an empty grid that is n^2 x n^2.  E.g. when n=3, the  //  grid should be 9x9.  Sudoku( int n );           //  Copy constructor.  The resulting Sudoku object should have the  //  same grid size and the same values in the grid.  Sudoku( Sudoku const& other );  //  Make an assignment to the Sudoku grid at the given row and  //  col(umn).  If a number is already stored at the row,col  //  location, overwrite it.  Do not check to see if the Sudoku  //  placement rules are violated.  Do nothing if the row or col  //  value is out of bounds (less than 0 or greater than n^2-1).  void assign( int row, int col, int number );  //  The number squared to make the grid, e.g. for a 9x9 grid the  //  value returned should be 3.  int n() const;  //  The number of rows (columns) in the grid.  When n=3, this value  //  is 9.  int n_squared() const;  //  Remove a number from the grid.  If there is no number there yet,  //  do nothing.   Do nothing if the row or col value is out of bounds.  void unassign( int row, int col );  //  Return true if and only if row and col are within the grid  //  bounds and the grid has a number stored at  row, col.  bool is_assigned( int row, int col ) const;  //  Return the number stored at the given row, col position, using  //  the "number" reference parameter to return the value.  Return  //  true if and only if the row, col values are within the valid  //  range AND a number has been assigned to the indicated location.  bool get_number( int row, int col, int & number ) const;  //  Return true if and only if the value of row, col are within the  //  valid range and the number can be correctly placed at the given  //  row,col position based on the row, column and grid block tests  //  described in the HW 3 handout.  Ignore numbers already placed at  //  the given row and col position in making this test (since this  //  function will be used to eliminate.   bool valid_assignment( int row, int col, int number ) const;  //  Using the reference parameter "numbers", return the possible  //  numbers, in increasing order, that can be placed in this row,col  //  position based on testing the row, the col and the grid block.  //  Ignore any number that might already be placed at the current  //  row,col position. If row or col are out of bounds then the  //  numbers vector should be empty.  void possible_numbers( int row, int col, vector<int> & numbers ) const;  //  Return true if and only if all values placed in the current grid  //  pass the row, col and grid block tests.  bool is_grid_valid() const;  public:  //  Add your other member functions here	vector< vector<int> > get_game()	{		return game;	}private:  //  Add your member variables here.	vector< vector<int> > game;};#endif