In article <54g41eF20necfU1@[EMAIL PROTECTED]
>,
"Gernot Frisch" <Me@[EMAIL PROTECTED]
> wrote:
> Hi,
>
> assume you have a list of products + price like:
> bigmc 3.59
> koke 1.29
> friez 0.79
> ...
>
> and some meals like:
> bigmc + koke + friez = 3.95
>
>
> I want to make a program that lets you select the pruducts and then
> get the cheapest combination, even if it has some extra stuff for you.
>
> I'd start by making a list of the products individually, then try to
> swap them with a menu and use a MinMax algorithm to go deeper into
> mixing.
>
> Is there any better idea to reach this?
Depending on the product count, if it's < 32 (or, say, up to about 128
or so), you can assign each product a bit, then the combos will have
several bits. So, maybe:
bigmc 0x01
koke 0x02
pepsi 0x04
friz 0x08
[...]
combo1 bigmc | koke | friz
combo2 bigmc | pepsi| fiz
[...]
etc. Then you can say
desired = X | Y | Z
and and-together the desired against the various combos to eliminate the
ones that don't have the correct items. (If desired & combo != desired,
then you're missing something.)
pick the lowest-prices combo from those remaining.
--
Please take off your pants or I won't read your e-mail.
I will not, no matter how "good" the deal, patronise any business which
sends
unsolicited commercial e-mail or that advertises in discussion newsgroups.


|