Kakuro Class Reference

This class is used to manipulate kakuro grids. More...

#include <kakuro.h>

List of all members.

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.

Detailed Description

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.

Definition at line 21 of file kakuro.h.


Member Function Documentation

void Kakuro::assignValue ( unsigned int  i,
unsigned int  j,
unsigned int  value 
)

Sets the value at a given point by modifying the gridStruct attribute.

Parameters:
jThe index of the column of the cell to modify.
iThe index of the line of the cell to modify.
valueThe value to assign to this cell.

Definition at line 236 of file kakuro.cpp.

std::vector< std::vector< unsigned int > > Kakuro::getGridStruc ( )

Geter for gridStruct.

Returns:
gridStruct.

Definition at line 266 of file kakuro.cpp.

std::vector< std::vector< unsigned int > > Kakuro::getHorizontalSum ( )

Geter for horizontalSum.

Returns:
horizontalSum.

Definition at line 269 of file kakuro.cpp.

unsigned int Kakuro::getMSize ( )

Geter for mSize.

Returns:
mSize.

Definition at line 260 of file kakuro.cpp.

unsigned int Kakuro::getNHints ( )

Geter for the number of hints.

Returns:
The size of sumsValue.

Definition at line 263 of file kakuro.cpp.

unsigned int Kakuro::getNSize ( )

Geter for nSize.

Returns:
nSize.

Definition at line 257 of file kakuro.cpp.

std::vector< std::vector< unsigned int > > Kakuro::getSumsAbscissa ( )

Geter for sumsAbscissa.

Returns:
sumsAbscissa.

Definition at line 281 of file kakuro.cpp.

std::vector< std::vector< unsigned int > > Kakuro::getSumsOrdinate ( )

Geter for sumsOrdinate.

Returns:
sumsOrdinate.

Definition at line 278 of file kakuro.cpp.

std::vector< unsigned int > Kakuro::getSumsValue ( )

Geter for sumsValue.

Returns:
sumsValue.

Definition at line 275 of file kakuro.cpp.

std::vector< std::vector< unsigned int > > Kakuro::getVerticalSum ( )

Geter for verticalSum.

Returns:
verticalSum.

Definition at line 272 of file kakuro.cpp.

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.

Parameters:
cellThe string containing the content of the cell to parse.
typeGets assigned to true if it is a free cell, false if we cannot write on it.
horizontalGets assigned to the value of the horizontal sum if any, 0 otherwise.
verticalThe 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.

Parameters:
inputThe stream from which to read.

Definition at line 112 of file kakuro.cpp.

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.

Parameters:
outThe stream to the file in which the grid should be printed.
isEmptyIf true then outputs '-' instead of '1' in the empty cells. Otherwise, pretty prints the complete grid.

Definition at line 152 of file kakuro.cpp.


Member Data Documentation

std::vector< std::vector<unsigned int> > Kakuro::gridStruct [private]

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.

Definition at line 40 of file kakuro.h.

std::vector< std::vector<unsigned int> > Kakuro::horizontalSum [private]

Contains zero if their is no information on horizontal sum, the value of the sum otherwise.

Definition at line 46 of file kakuro.h.

unsigned int Kakuro::mSize [private]

The number of columns in the kakuro grid.

Definition at line 27 of file kakuro.h.

unsigned int Kakuro::nSize [private]

The number of lines in the kakuro grid.

Definition at line 32 of file kakuro.h.

std::vector< std::vector<unsigned int> > Kakuro::sumsAbscissa [private]

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.

Definition at line 68 of file kakuro.h.

std::vector< std::vector<unsigned int> > Kakuro::sumsOrdinate [private]

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.

Definition at line 76 of file kakuro.h.

std::vector<unsigned int> Kakuro::sumsValue [private]

Contains the successive values of the sums given by the hints. The index of each hint matches that of the sumsAbscissa and sumsOrdinate attribute.

Definition at line 60 of file kakuro.h.

std::vector< std::vector<unsigned int> > Kakuro::verticalSum [private]

Contains zero if their is no information on vertical sum, the value of the sum otherwise.

Definition at line 52 of file kakuro.h.


The documentation for this class was generated from the following files:
 All Classes Files Functions Variables