Example: Grocery puzzle More...
Public Member Functions | |
Grocery (const Options &opt) | |
The actual model. More... | |
Grocery (bool share, Grocery &s) | |
Constructor for cloning s. More... | |
virtual Space * | copy (bool share) |
Copy 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 | |
IntVarArray | abcd |
The price of each item. More... | |
Static Protected Attributes | |
static const int | s = 711 |
Sum and product of prices. More... | |
static const int | p = 711 * 100 * 100 * 100 |
Decimal product of prices. More... | |
Related Functions | |
(Note that these are not member functions.) | |
int | main (int argc, char *argv[]) |
Main-function. More... | |
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: Grocery puzzle
A kid goes into a grocery store and buys four items. The cashier charges $7.11, the kid pays and is about to leave when the cashier calls the kid back, and says ''Hold on, I multiplied the four items instead of adding them; I'll try again; Hah, with adding them the price still comes to $7.11''. What were the prices of the four items?
The model is taken from: Christian Schulte, Gert Smolka, Finite Domain Constraint Programming in Oz. A Tutorial. 2001. Available from: http://www.mozart-oz.org/documentation/fdt/
Definition at line 60 of file grocery.cpp.
|
inline |
The actual model.
Definition at line 70 of file grocery.cpp.
|
inline |
Constructor for cloning s.
Definition at line 86 of file grocery.cpp.
|
inlinevirtual |
Copy during cloning.
Definition at line 92 of file grocery.cpp.
|
inlinevirtual |
Print solution.
Reimplemented from Gecode::Driver::ScriptBase< BaseSpace >.
Definition at line 98 of file grocery.cpp.
|
related |
Main-function.
Definition at line 107 of file grocery.cpp.
|
protected |
The price of each item.
Definition at line 63 of file grocery.cpp.
|
staticprotected |
Sum and product of prices.
Definition at line 65 of file grocery.cpp.
|
staticprotected |
Decimal product of prices.
Definition at line 67 of file grocery.cpp.