what i am trying to do

T

tony collier

ok - this is what i am trying to do and there is probably a much better
way which this newbie hasn't read or thought about yet.

i am getting prices from x number of suppliers who all quote me a
different individual price for each of y items. no one supplier is always
cheaper than the others.

IDEAL SCENARIO:

no. of suppliers: x (unlimited)

no. of items: y (unlimited)

i then calculate all the different combination of items from mixed
suppliers to get the lowest overall price possible. this is where my huge
array comes in to store the values, as the formula to work out number of
combinations =

no.of supplier ^ (to the power of) no. of items.

I have so far only been able to go up to x=11, and y=7 before running
into memory constraints.

Items must be able to be added/deleted like in a cart until user
checksout, so no running calculation can take place to try and crunch
numbers as i go. this is why i can't see how array can be made any
smaller.

any ideas on how to make x and y larger (other than investing in more
memory) would be greatly appreciated.


Incidentally, is there any way to initalize all elements in the array to
zero in one fell swoop rather than looping through them all?



many thanks tc.
 
F

Frank Oquendo

tony said:
no.of supplier ^ (to the power of) no. of items.

So you're assuming every supplier carries every item? I would change my
logic to have items indicate which suppliers carry them. Sound to me
like you need to give up the array approach and use a database. If a
true database is out of the question, you can always store the
information as an XML file and load that into a DataSet.
Incidentally, is there any way to initalize all elements in the array
to zero in one fell swoop rather than looping through them all?

Nope. Lovely, isn't it? A C++ feature I actually miss. Who knew?

--
There are 10 kinds of people. Those who understand binary and those who
don't.

http://code.acadx.com
(Pull the pin to reply)
 
J

Jay B. Harlow [MVP - Outlook]

Tony,
no.of supplier ^ (to the power of) no. of items.
It sounds like you may want to consider a different storage mechanism and/or
possibly a different algorithm.
Incidentally, is there any way to initalize all elements in the array to
zero in one fell swoop rather than looping through them all?

Have you looked at the System.Array.Clear method?

Hope this helps
Jay
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top