Example: Kakuro More...
Public Types | |
enum | { MODEL_DECOMPOSE , MODEL_COMBINE } |
Model variants. More... |
Public Member Functions | |
IntVar | init (IntVar &x) |
Init the variable x if necessary. | |
void | distinctlinear (Cache &dc, const IntVarArgs &x, int c, const SizeOptions &opt) |
Post a distinct-linear constraint on variables x with sum c. | |
Kakuro (const SizeOptions &opt) | |
The actual problem. | |
Kakuro (Kakuro &s) | |
Constructor for cloning s. | |
virtual Space * | copy (void) |
Perform copying during cloning. | |
virtual void | print (std::ostream &os) const |
Print solution. | |
Public Member Functions inherited from Gecode::Driver::ScriptBase< Driver::IgnoreStepOption< Space > > | |
ScriptBase (const Options &opt) | |
Constructor. | |
ScriptBase (ScriptBase &e) | |
Constructor used for cloning. | |
virtual void | compare (const Space &home, std::ostream &os) const |
Compare with s. | |
Public Member Functions inherited from Gecode::Driver::IgnoreStepOption< BaseSpace > | |
IgnoreStepOption (const Options &) | |
Constructor. | |
IgnoreStepOption (BaseSpace &e) | |
Constructor used for cloning. |
Protected Attributes | |
const int | w |
Width of board. | |
const int | h |
Height of board. | |
IntVarArray | f |
Variables for fields of board. |
Related Symbols | |
(Note that these are not member symbols.) | |
int | main (int argc, char *argv[]) |
Main-function. |
Kakuro specifications | |
Each specification starts with two integers for width and height, followed by entries for vertical constraints, an integer -1 (signalling the end of the vertical constraints), entries for the horizontal constraints, and, finally, an integer -1. Each entry consists of four integers:
The example are taken from the website of Nikoli (from the free section). Thanks to Nikoli for their great puzzles and their brilliant website: www.nikoli.com. | |
const int | k0 [] |
Array of all examples. | |
const int | k1 [] |
Array of all examples. | |
const int | k2 [] |
Array of all examples. | |
const int | k3 [] |
Array of all examples. | |
const int | k4 [] |
Array of all examples. | |
const int | k5 [] |
Array of all examples. | |
const int | k6 [] |
Array of all examples. | |
const int | k7 [] |
Array of all examples. | |
const int | k8 [] |
Array of all examples. | |
const int | k9 [] |
Array of all examples. | |
const int * | examples [] |
Array of all examples. | |
const unsigned int | n_examples = sizeof(examples)/sizeof(const int*) |
Number of examples. | |
TupleSet | generate (int n, int c) |
Generate tuple set for n distinct variables with sum c. |
Additional Inherited Members | |
Static Public Member Functions inherited from Gecode::Driver::ScriptBase< Driver::IgnoreStepOption< Space > > | |
static std::ostream & | select_ostream (const char *sn, std::ofstream &ofs) |
Choose output stream according to sn. | |
static void | run (const Options &opt, Script *s=NULL) |
Example: Kakuro
Another puzzle in the style of Sudoku.
Note that "Modeling and Programming with Gecode" uses this example as a case study.
Definition at line 473 of file kakuro.cpp.
anonymous enum |
Model variants.
Enumerator | |
---|---|
MODEL_DECOMPOSE | Decompose constraints. |
MODEL_COMBINE | Combine distinct and linear constraint. |
Definition at line 480 of file kakuro.cpp.
|
inline |
The actual problem.
Definition at line 537 of file kakuro.cpp.
|
inline |
Constructor for cloning s.
Definition at line 577 of file kakuro.cpp.
Init the variable x if necessary.
Definition at line 485 of file kakuro.cpp.
|
inline |
Post a distinct-linear constraint on variables x with sum c.
Definition at line 491 of file kakuro.cpp.
|
inlinevirtual |
Perform copying during cloning.
Definition at line 582 of file kakuro.cpp.
|
inlinevirtual |
Print solution.
Reimplemented from Gecode::Driver::ScriptBase< Driver::IgnoreStepOption< Space > >.
Definition at line 587 of file kakuro.cpp.
|
Array of all examples.
Definition at line 68 of file kakuro.cpp.
|
Array of all examples.
Definition at line 89 of file kakuro.cpp.
|
Array of all examples.
Definition at line 110 of file kakuro.cpp.
|
Array of all examples.
Definition at line 130 of file kakuro.cpp.
|
Array of all examples.
Definition at line 150 of file kakuro.cpp.
|
Array of all examples.
Definition at line 182 of file kakuro.cpp.
|
Array of all examples.
Definition at line 216 of file kakuro.cpp.
|
Array of all examples.
Definition at line 249 of file kakuro.cpp.
|
Array of all examples.
Definition at line 286 of file kakuro.cpp.
|
Array of all examples.
Definition at line 325 of file kakuro.cpp.
|
|
Number of examples.
Definition at line 366 of file kakuro.cpp.
|
Generate tuple set for n distinct variables with sum c.
Definition at line 404 of file kakuro.cpp.
|
Main-function.
Definition at line 606 of file kakuro.cpp.
|
protected |
Width of board.
Definition at line 475 of file kakuro.cpp.
|
protected |
Height of board.
Definition at line 476 of file kakuro.cpp.
|
protected |
Variables for fields of board.
Definition at line 477 of file kakuro.cpp.