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. More... | |
void | distinctlinear (Cache &dc, const IntVarArgs &x, int c, const SizeOptions &opt) |
Post a distinct-linear constraint on variables x with sum c. More... | |
Kakuro (const SizeOptions &opt) | |
The actual problem. More... | |
Kakuro (bool share, Kakuro &s) | |
Constructor for cloning s. More... | |
virtual Space * | copy (bool share) |
Perform copying during cloning. More... | |
virtual void | print (std::ostream &os) const |
Print solution. More... | |
![]() | |
ScriptBase (void) | |
Default constructor. More... | |
ScriptBase (bool share, ScriptBase &e) | |
Constructor used for cloning. More... | |
virtual void | compare (const Space &, std::ostream &os) const |
Compare with s. More... | |
Protected Attributes | |
const int | w |
Width of board. More... | |
const int | h |
Height of board. More... | |
IntVarArray | f |
Variables for fields of board. More... | |
Related Functions | |
(Note that these are not member functions.) | |
const int * | examples [] |
Array of all examples. More... | |
TupleSet | generate (int n, int c) |
Generate tuple set for n distinct variables with sum c. More... | |
int | main (int argc, char *argv[]) |
Main-function. More... | |
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 [] |
const int | k1 [] |
const int | k2 [] |
const int | k3 [] |
const int | k4 [] |
const int | k5 [] |
const int | k6 [] |
const int | k7 [] |
const int | k8 [] |
const int | k9 [] |
Additional Inherited Members | |
![]() | |
static std::ostream & | select_ostream (const char *name, std::ofstream &ofs) |
Choose output stream according to name. More... | |
template<class Script , template< class > class Engine, class Options > | |
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 477 of file kakuro.cpp.
|
inline |
The actual problem.
Definition at line 541 of file kakuro.cpp.
|
inline |
Constructor for cloning s.
Definition at line 580 of file kakuro.cpp.
Init the variable x if necessary.
Definition at line 489 of file kakuro.cpp.
|
inline |
Post a distinct-linear constraint on variables x with sum c.
Definition at line 495 of file kakuro.cpp.
|
inlinevirtual |
Perform copying during cloning.
Definition at line 585 of file kakuro.cpp.
|
inlinevirtual |
Print solution.
Reimplemented from Gecode::Driver::ScriptBase< BaseSpace >.
Definition at line 590 of file kakuro.cpp.
|
related |
Definition at line 72 of file kakuro.cpp.
|
related |
Definition at line 93 of file kakuro.cpp.
|
related |
Definition at line 114 of file kakuro.cpp.
|
related |
Definition at line 134 of file kakuro.cpp.
|
related |
Definition at line 154 of file kakuro.cpp.
|
related |
Definition at line 186 of file kakuro.cpp.
|
related |
Definition at line 220 of file kakuro.cpp.
|
related |
Definition at line 253 of file kakuro.cpp.
|
related |
Definition at line 290 of file kakuro.cpp.
|
related |
Definition at line 329 of file kakuro.cpp.
|
related |
|
related |
Generate tuple set for n distinct variables with sum c.
Definition at line 408 of file kakuro.cpp.
|
related |
Main-function.
Definition at line 609 of file kakuro.cpp.
|
protected |
Width of board.
Definition at line 479 of file kakuro.cpp.
|
protected |
Height of board.
Definition at line 480 of file kakuro.cpp.
|
protected |
Variables for fields of board.
Definition at line 481 of file kakuro.cpp.