This class is used to manipulate kakuro grids. More...
#include <kakuro.h>
Public Member Functions | |
void | printGrids () |
Pretty prints the gridStruct, verticalSum and horizontalSum. | |
void | parseGrid (std::istream *input) |
Reads a kakoru formatted stream and assigns the attributes of this instance accordingly. Once the call to this method is over, this instance contains a complete description of the kakuro grid. | |
void | printToStream (std::ostream &, bool) |
Pretty prints the kakuro grid in a file. | |
void | grids2sums () |
Uses the grids gridStruct, horizontalSum and verticalSum to assign the sumsValue, sumsAbscissa and sumsOrdinate attributes. | |
void | assignValue (unsigned int, unsigned int, unsigned int) |
Sets the value at a given point by modifying the gridStruct attribute. | |
unsigned int | getNSize () |
Geter for nSize. | |
unsigned int | getMSize () |
Geter for mSize. | |
unsigned int | getNHints () |
Geter for the number of hints. | |
std::vector< std::vector < unsigned int > > | getGridStruc () |
Geter for gridStruct. | |
std::vector< std::vector < unsigned int > > | getHorizontalSum () |
Geter for horizontalSum. | |
std::vector< std::vector < unsigned int > > | getVerticalSum () |
Geter for verticalSum. | |
std::vector< unsigned int > | getSumsValue () |
Geter for sumsValue. | |
std::vector< std::vector < unsigned int > > | getSumsOrdinate () |
Geter for sumsOrdinate. | |
std::vector< std::vector < unsigned int > > | getSumsAbscissa () |
Geter for sumsAbscissa. | |
Static Public Member Functions | |
static void | parseCell (std::string cell, bool *type, unsigned int *horizontal, unsigned int *vertical) |
Studies a cell in order to see whether it should be filled in or contains a sum to reach. | |
Private Attributes | |
unsigned int | mSize |
The number of columns in the kakuro grid. | |
unsigned int | nSize |
The number of lines in the kakuro grid. | |
std::vector< std::vector < unsigned int > > | gridStruct |
The structure of the grid. Contains 0 if the cell cannot be filled, 1 otherwise. This matrix is of the same size as the kakuro. It can receive the values at each point of the grid. | |
std::vector< std::vector < unsigned int > > | horizontalSum |
Contains zero if their is no information on horizontal sum, the value of the sum otherwise. | |
std::vector< std::vector < unsigned int > > | verticalSum |
Contains zero if their is no information on vertical sum, the value of the sum otherwise. | |
std::vector< unsigned int > | sumsValue |
Contains the successive values of the sums given by the hints. The index of each hint matches that of the sumsAbscissa and sumsOrdinate attribute. | |
std::vector< std::vector < unsigned int > > | sumsAbscissa |
Contains the successive lists of abscissas of the cells involved in each sum. The index of each hint matches that of the sumsValue and sumsOrdinate attribute. | |
std::vector< std::vector < unsigned int > > | sumsOrdinate |
Contains the successive lists of ordinates of the cells involved in each sum. The index of each hint matches that of the sumsValue and sumsAbscissa attribute. |
This class is used to manipulate kakuro grids.
It allows several operations such as parsing a file correctly formatted to generate the kakuro instance or returning several arrays and grids to be used by a program working on the kakuro.
void Kakuro::assignValue | ( | unsigned int | i, |
unsigned int | j, | ||
unsigned int | value | ||
) |
Sets the value at a given point by modifying the gridStruct attribute.
j | The index of the column of the cell to modify. |
i | The index of the line of the cell to modify. |
value | The value to assign to this cell. |
Definition at line 236 of file kakuro.cpp.
std::vector< std::vector< unsigned int > > Kakuro::getGridStruc | ( | ) |
std::vector< std::vector< unsigned int > > Kakuro::getHorizontalSum | ( | ) |
unsigned int Kakuro::getMSize | ( | ) |
unsigned int Kakuro::getNHints | ( | ) |
Geter for the number of hints.
Definition at line 263 of file kakuro.cpp.
unsigned int Kakuro::getNSize | ( | ) |
std::vector< std::vector< unsigned int > > Kakuro::getSumsAbscissa | ( | ) |
std::vector< std::vector< unsigned int > > Kakuro::getSumsOrdinate | ( | ) |
std::vector< unsigned int > Kakuro::getSumsValue | ( | ) |
std::vector< std::vector< unsigned int > > Kakuro::getVerticalSum | ( | ) |
void Kakuro::grids2sums | ( | ) |
Uses the grids gridStruct, horizontalSum and verticalSum to assign the sumsValue, sumsAbscissa and sumsOrdinate attributes.
Definition at line 187 of file kakuro.cpp.
void Kakuro::parseCell | ( | std::string | cell, |
bool * | type, | ||
unsigned int * | horizontal, | ||
unsigned int * | vertical | ||
) | [static] |
Studies a cell in order to see whether it should be filled in or contains a sum to reach.
cell | The string containing the content of the cell to parse. |
type | Gets assigned to true if it is a free cell, false if we cannot write on it. |
horizontal | Gets assigned to the value of the horizontal sum if any, 0 otherwise. |
vertical | The same as vertical sum, except that it obviously concerns the vertical sum. |
Definition at line 34 of file kakuro.cpp.
void Kakuro::parseGrid | ( | std::istream * | input | ) |
Reads a kakoru formatted stream and assigns the attributes of this instance accordingly. Once the call to this method is over, this instance contains a complete description of the kakuro grid.
input | The stream from which to read. |
Definition at line 112 of file kakuro.cpp.
void Kakuro::printGrids | ( | ) |
Pretty prints the gridStruct, verticalSum and horizontalSum.
Definition at line 82 of file kakuro.cpp.
void Kakuro::printToStream | ( | std::ostream & | out, |
bool | isEmpty | ||
) |
Pretty prints the kakuro grid in a file.
out | The stream to the file in which the grid should be printed. |
isEmpty | If true then outputs '-' instead of '1' in the empty cells. Otherwise, pretty prints the complete grid. |
Definition at line 152 of file kakuro.cpp.
std::vector< std::vector<unsigned int> > Kakuro::gridStruct [private] |
std::vector< std::vector<unsigned int> > Kakuro::horizontalSum [private] |
unsigned int Kakuro::mSize [private] |
unsigned int Kakuro::nSize [private] |
std::vector< std::vector<unsigned int> > Kakuro::sumsAbscissa [private] |
std::vector< std::vector<unsigned int> > Kakuro::sumsOrdinate [private] |
std::vector<unsigned int> Kakuro::sumsValue [private] |
std::vector< std::vector<unsigned int> > Kakuro::verticalSum [private] |