Generated on Tue May 22 09:40:48 2018 for Gecode by doxygen 1.6.3

# Kakuro Class Reference [Example scripts (models)]

Example: Kakuro More...

List of all members.

## 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 Spacecopy (void)
Perform copying during cloning.
virtual void print (std::ostream &os) const
Print solution.

## Protected Attributes

const int w
Width of board.
const int h
Height of board.
IntVarArray f
Variables for fields of board.

## Related Functions

(Note that these are not member functions.)

const int * examples []
Array of all examples.
TupleSet generate (int n, int c)
Generate tuple set for n distinct variables with sum c.

## 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 x-coordinate of the hint
• the y-coordinate of the hint
• the number of fields in the respective direction
• the sum of the fields

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 []

## Detailed Description

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.

## Member Enumeration Documentation

 anonymous enum

Model variants.

Enumerator:
 MODEL_DECOMPOSE Decompose constraints. MODEL_COMBINE Combine distinct and linear constraint.

Definition at line 480 of file kakuro.cpp.

## Constructor & Destructor Documentation

 Kakuro::Kakuro ( const SizeOptions & opt ) ` [inline]`

The actual problem.

Definition at line 537 of file kakuro.cpp.

 Kakuro::Kakuro ( Kakuro & s ) ` [inline]`

Constructor for cloning s.

Definition at line 577 of file kakuro.cpp.

## Member Function Documentation

 IntVar Kakuro::init ( IntVar & x ) ` [inline]`

Init the variable x if necessary.

Definition at line 485 of file kakuro.cpp.

 void Kakuro::distinctlinear ( Cache & dc, const IntVarArgs & x, int c, const SizeOptions & opt ) ` [inline]`

Post a distinct-linear constraint on variables x with sum c.

Definition at line 491 of file kakuro.cpp.

 virtual Space* Kakuro::copy ( void ) ` [inline, virtual]`

Perform copying during cloning.

Definition at line 582 of file kakuro.cpp.

 virtual void Kakuro::print ( std::ostream & os ) const` [inline, virtual]`

Print solution.

Reimplemented from Gecode::Driver::ScriptBase< BaseSpace >.

Definition at line 587 of file kakuro.cpp.

## Friends And Related Function Documentation

 const int k0[]` [related]`
Initial value:
``` {

12,10,

2, 0, 5,16,     3, 0, 2, 4,     5, 0, 3, 6,     6, 0, 2, 4,
7, 0, 5,15,    10, 0, 3, 6,    11, 0, 3, 7,     1, 1, 3, 7,
9, 1, 5,16,     4, 2, 2, 5,     8, 2, 2, 3,     3, 3, 5,16,
6, 3, 3, 8,     5, 4, 5,15,    10, 4, 5,15,     4, 5, 2, 3,
8, 5, 2, 4,    11, 5, 3, 7,     1, 6, 3, 6,     2, 6, 3, 7,
7, 6, 3, 7,     6, 7, 2, 3,     9, 7, 2, 4,    -1,

1, 1, 2, 7,     4, 1, 3, 9,     9, 1, 2, 4,     0, 2, 3, 7,
4, 2, 3, 7,     8, 2, 3, 6,     0, 3, 2, 3,     3, 3, 2, 4,
6, 3, 5,16,     0, 4, 4,10,     5, 4, 4,10,     1, 5, 2,10,
4, 5, 3, 6,     8, 5, 2, 5,     2, 6, 4,10,     7, 6, 4,12,
0, 7, 5,16,     6, 7, 2, 4,     9, 7, 2, 4,     0, 8, 3, 7,
4, 8, 3, 8,     8, 8, 3, 6,     0, 9, 2, 3,     4, 9, 3, 7,
8, 9, 2, 3,    -1
}
```

Definition at line 68 of file kakuro.cpp.

 const int k1[]` [related]`
Initial value:
``` {

12,10,

1, 0, 2, 4,     2, 0, 5,15,     5, 0, 5,18,     6, 0, 2,12,
7, 0, 3, 8,    10, 0, 3,24,    11, 0, 3,23,     3, 1, 2, 7,
9, 1, 3,24,     4, 2, 5,16,     8, 2, 5,35,     1, 3, 2,12,
6, 3, 3,17,     7, 4, 5,34,    10, 4, 5,34,    11, 4, 2,16,
3, 5, 3, 6,     1, 6, 3, 7,     2, 6, 3, 6,     5, 6, 3,23,
9, 6, 2,10,     6, 7, 2,14,    11, 7, 2,10,    -1,

0, 1, 2, 3,     4, 1, 3,15,     9, 1, 2,16,     0, 2, 3, 6,
4, 2, 3, 7,     8, 2, 3,24,     1, 3, 4,11,     6, 3, 5,34,
0, 4, 2,14,     3, 4, 3,23,     7, 4, 2,14,     0, 5, 2, 7,
3, 5, 5,15,     9, 5, 2,17,     2, 6, 2, 6,     5, 6, 3,23,
9, 6, 2,13,     0, 7, 5,16,     6, 7, 4,30,     0, 8, 3, 6,
4, 8, 3,23,     8, 8, 3, 7,     0, 9, 2, 4,     4, 9, 3,24,
9, 9, 2,17,    -1
}
```

Definition at line 89 of file kakuro.cpp.

 const int k2[]` [related]`
Initial value:
``` {

12,10,

2, 0, 5,15,     3, 0, 2, 3,     7, 0, 3, 7,     8, 0, 4,23,
9, 0, 2,12,    10, 0, 3,20,    11, 0, 3, 9,     4, 1, 3, 7,
5, 1, 4,10,     1, 2, 3, 6,     6, 2, 5,15,     9, 3, 2,16,
3, 4, 2, 3,     7, 4, 4,13,    10, 4, 5,35,    11, 4, 3,23,
4, 5, 4,11,     8, 5, 3,23,     1, 6, 3,23,     2, 6, 3,14,
5, 6, 3,11,     3, 7, 2,13,     9, 7, 2,17,    -1,

1, 1, 2, 4,     6, 1, 5,15,     1, 2, 4,11,     6, 2, 5,34,
0, 3, 2, 3,     3, 3, 5,15,     9, 3, 2,10,     0, 4, 2, 4,
3, 4, 3, 6,     7, 4, 2,17,     0, 5, 3, 7,     4, 5, 3, 8,
8, 5, 3,18,     2, 6, 2, 3,     5, 6, 3,11,     9, 6, 2,16,
0, 7, 2,16,     3, 7, 5,16,     9, 7, 2,17,     0, 8, 5,16,
6, 8, 4,30,     0, 9, 5,35,     8, 9, 2,17,    -1
}
```

Definition at line 110 of file kakuro.cpp.

 const int k3[]` [related]`
Initial value:
``` {

12,10,

3, 0, 3, 7,     4, 0, 6,21,     7, 0, 4,29,     8, 0, 2,17,
10, 0, 4,29,    11, 0, 3,23,     2, 1, 3, 6,     6, 1, 2,16,
9, 1, 4,14,     1, 2, 2, 4,     5, 2, 2, 3,     8, 3, 6,22,
3, 4, 4,10,     2, 5, 4,11,     5, 5, 4,10,     7, 5, 2,10,
10, 5, 3,24,    11, 5, 2,16,     1, 6, 3, 7,     6, 6, 2, 9,
9, 6, 3,23,     4, 7, 2, 4,    -1,

2, 1, 2, 4,     6, 1, 2,17,     9, 1, 2,16,     1, 2, 3, 6,
5, 2, 6,39,     0, 3, 7,28,     8, 3, 3,24,     0, 4, 2, 3,
3, 4, 2, 3,     6, 4, 4,20,     2, 5, 2, 9,     7, 5, 2, 4,
1, 6, 4,10,     6, 6, 2, 3,     9, 6, 2,16,     0, 7, 3, 6,
4, 7, 7,42,     0, 8, 6,21,     7, 8, 3,21,     0, 9, 2, 4,
3, 9, 2, 3,     7, 9, 2,16,    -1
}
```

Definition at line 130 of file kakuro.cpp.

 const int k4[]` [related]`
Initial value:
``` {

20,12,

3, 0, 3,21,     4, 0, 2, 4,     5, 0, 4,11,     8, 0, 2, 8,
9, 0, 3, 7,    11, 0, 2, 3,    12, 0, 3, 6,    15, 0, 6,39,
16, 0, 2, 3,    17, 0, 3,23,     2, 1, 5,15,     6, 1, 4,10,
10, 1, 4,11,    14, 1, 4,11,    18, 1, 3, 6,     1, 2, 3,24,
7, 2, 4,14,    13, 2, 2,10,    19, 2, 2,16,     4, 3, 5,18,
8, 3, 4,10,    11, 3, 4,12,    16, 3, 5,33,     3, 4, 3,23,
9, 4, 4,29,    12, 4, 4,30,    17, 4, 3,18,     5, 5, 6,38,
13, 5, 4,29,    18, 5, 5,15,     6, 6, 4,25,    10, 6, 4,12,
14, 6, 4,28,    19, 6, 3,21,     1, 7, 2, 4,     2, 7, 3, 7,
7, 7, 2, 7,    15, 7, 4,11,     3, 8, 3,19,     8, 8, 3,24,
11, 8, 3, 7,    17, 8, 3, 6,     4, 9, 2,16,     9, 9, 2,16,
12, 9, 2,17,    16, 9, 2, 5,    -1,

2, 1, 3, 7,     7, 1, 2, 4,    10, 1, 2, 4,    14, 1, 3,19,
1, 2, 5,18,     7, 2, 5,15,    13, 2, 5,16,     0, 3, 3,21,
4, 3, 3, 6,     8, 3, 2, 3,    11, 3, 4,11,    16, 3, 3,20,
0, 4, 2,14,     3, 4, 5,15,     9, 4, 2, 3,    12, 4, 4,29,
17, 4, 2, 8,     0, 5, 4,27,     5, 5, 7,42,    13, 5, 4,12,
1, 6, 4,12,     6, 6, 3, 8,    10, 6, 3,20,    14, 6, 4,29,
2, 7, 4,28,     7, 7, 7,28,    15, 7, 4,28,     0, 8, 2, 3,
3, 8, 4,11,     8, 8, 2,10,    11, 8, 5,35,    17, 8, 2,10,
0, 9, 3, 6,     4, 9, 4,30,     9, 9, 2, 3,    12, 9, 3,19,
16, 9, 3, 7,     1,10, 5,34,     7,10, 5,34,    13,10, 5,17,
2,11, 3,23,     7,11, 2,17,    10,11, 2,10,    14,11, 3, 6,
-1
}
```

Definition at line 150 of file kakuro.cpp.

 const int k5[]` [related]`

Definition at line 182 of file kakuro.cpp.

 const int k6[]` [related]`

Definition at line 216 of file kakuro.cpp.

 const int k7[]` [related]`

Definition at line 249 of file kakuro.cpp.

 const int k8[]` [related]`

Definition at line 286 of file kakuro.cpp.

 const int k9[]` [related]`

Definition at line 325 of file kakuro.cpp.

 const int* examples[]` [related]`
Initial value:
``` {
&k0[0], &k1[0], &k2[0], &k3[0], &k4[0],
&k5[0], &k6[0], &k7[0], &k8[0], &k9[0]
}
```

Array of all examples.

Definition at line 361 of file kakuro.cpp.

 TupleSet generate ( int n, int c ) ` [related]`

Generate tuple set for n distinct variables with sum c.

Definition at line 404 of file kakuro.cpp.

## Member Data Documentation

 const int Kakuro::w` [protected]`

Width of board.

Definition at line 475 of file kakuro.cpp.

 const int Kakuro::h` [protected]`

Height of board.

Definition at line 476 of file kakuro.cpp.

 IntVarArray Kakuro::f` [protected]`

Variables for fields of board.

Definition at line 477 of file kakuro.cpp.

The documentation for this class was generated from the following file: