Example: Grocery puzzle More...
Public Member Functions | |
Grocery (const Options &opt) | |
The actual model. | |
Grocery (Grocery &s) | |
Constructor for cloning s. | |
virtual Space * | copy (void) |
Copy during cloning. | |
virtual void | print (std::ostream &os) const |
Print solution. | |
![]() | |
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. | |
Protected Attributes | |
IntVarArray | abcd |
The price of each item. | |
Static Protected Attributes | |
static const int | s = 711 |
Sum and product of prices. | |
static const int | p = 711 * 100 * 100 * 100 |
Decimal product of prices. | |
Related Symbols | |
(Note that these are not member symbols.) | |
int | main (int argc, char *argv[]) |
Main-function. | |
Additional Inherited Members | |
![]() | |
static std::ostream & | select_ostream (const char *sn, std::ofstream &ofs) |
Choose output stream according to sn. | |
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 56 of file grocery.cpp.
|
inline |
The actual model.
Definition at line 66 of file grocery.cpp.
|
inline |
Constructor for cloning s.
Definition at line 83 of file grocery.cpp.
|
inlinevirtual |
Copy during cloning.
Definition at line 89 of file grocery.cpp.
|
inlinevirtual |
Print solution.
Reimplemented from Gecode::Driver::ScriptBase< BaseSpace >.
Definition at line 95 of file grocery.cpp.
|
related |
Main-function.
Definition at line 104 of file grocery.cpp.
|
protected |
The price of each item.
Definition at line 59 of file grocery.cpp.
|
staticprotected |
Sum and product of prices.
Definition at line 61 of file grocery.cpp.
|
staticprotected |
Decimal product of prices.
Definition at line 63 of file grocery.cpp.