473,399 Members | 3,603 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

this is what i am trying to achieve

ok . thanks everyone for your advice so far. 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.

no. of suppliers: x (preferably unlimited)

no. of items: y (again, preferably unlimited)

i then calculate all the different combination of items from mixed
suppliers. The formula to work out number of combinations =

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

this requires creating an array of y dimensions with x elements per
dimension to store all combinations

as you will now understand , 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.

hope this all makes sense. any ideas to do this in a better way 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?

many thanks tc.
Nov 15 '05 #1
12 1234
tony collier wrote:
hope this all makes sense. any ideas to do this in a better way
would be greatly appreciated.


Is this a triplicate post or did you not like the advice you've received
thus far?

The better way you ask for is to use a DataSet containing a table for
items and suppliers. In addition, a third table will hold rows
indicating which items may be obtained from which suppliers and at what
price, lead time, etc.

This cuts the amount of information you're manipulating dramatically
since it does not operate on the assumption that all items may be
procured from all suppliers. It also removes a lot of unneeded
complexity since you can pull information using standard SQL.

This solution is simple, scalable and maintainable.

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

http://code.acadx.com
(Pull the pin to reply)
Nov 15 '05 #2
Sounds like an interesting problem, is this a high school or college
assignment ?-)
"tony collier" <me*****@hotmail.com> wrote in message
news:Xn*************************@140.99.99.130...
ok . thanks everyone for your advice so far. 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.

no. of suppliers: x (preferably unlimited)

no. of items: y (again, preferably unlimited)

i then calculate all the different combination of items from mixed
suppliers. The formula to work out number of combinations =

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

this requires creating an array of y dimensions with x elements per
dimension to store all combinations

as you will now understand , 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.

hope this all makes sense. any ideas to do this in a better way 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?

many thanks tc.

Nov 15 '05 #3
no - i is just a personal project to extend the functionality of a
website i have created.
Nov 15 '05 #4
How did you come up with the formula x^y??

If there are max y items and max x suppliers, isn't the array size x*y???

Like Frank suggested, a DataSet should do the work for you pretty well. If
you insist on going with an array, do a multi-dimensional array -
array[x][y] where x is supplier and y is item index.

-vJ

"tony collier" <me*****@hotmail.com> wrote in message
news:Xn*************************@140.99.99.130...
ok . thanks everyone for your advice so far. 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.

no. of suppliers: x (preferably unlimited)

no. of items: y (again, preferably unlimited)

i then calculate all the different combination of items from mixed
suppliers. The formula to work out number of combinations =

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

this requires creating an array of y dimensions with x elements per
dimension to store all combinations

as you will now understand , 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.

hope this all makes sense. any ideas to do this in a better way 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?

many thanks tc.

Nov 15 '05 #5
"Vijaye Raji" <no************@hotmail.com> wrote in
news:#G**************@tk2msftngp13.phx.gbl:
How did you come up with the formula x^y??
If there are max y items and max x suppliers, isn't the array size
x*y???

Like Frank suggested, a DataSet should do the work for you pretty
well. If you insist on going with an array, do a multi-dimensional
array - array[x][y] where x is supplier and y is item index.

-vJ

no , it is x^y. i can't proove it , i just tried a few trivial cases and
noticed a pattern. i am sure someone could post mathematical proof but
that isn't really the issue here - you'll just have to trust me or work
through a few examples yourself.

don't know much about [x][y] ( i thought this was for jagged arrays) or
DataSets. any good sites to read about these?
Nov 15 '05 #6
"tony collier" <me*****@hotmail.com> wrote in message news:Xn******************************@140.99.99.13 0...
no , it is x^y. i can't proove it , i just tried a few trivial cases and
noticed a pattern. i am sure someone could post mathematical proof but
that isn't really the issue here - you'll just have to trust me or work
through a few examples yourself.


From the description you gave it should be x*y, either x^y is wrong or your description is wrong.

--
Michael Culley
Nov 15 '05 #7
"Michael Culley" <mc*****@NOSPAMoptushome.com.au> wrote in
news:#A**************@TK2MSFTNGP10.phx.gbl:
"tony collier" <me*****@hotmail.com> wrote in message
news:Xn******************************@140.99.99.13 0...
no , it is x^y. i can't proove it , i just tried a few trivial cases
and noticed a pattern. i am sure someone could post mathematical
proof but that isn't really the issue here - you'll just have to
trust me or work through a few examples yourself.


From the description you gave it should be x*y, either x^y is wrong or
your description is wrong.

--
Michael Culley


i want all combinations in all different orders eg. with 3 suppliers
a,b,c and 2 items I want:

| a | b | c
===================================
1 | | |
===================================
2 | | |
a,a
a,b
a,c
b,a
b,b
b,c
c,a
c,b
c,c

= 3^2 = 9 combinations in all possible orders.

hope this is now clear.
Nov 15 '05 #8
tony collier wrote:
= 3^2 = 9 combinations in all possible orders.

hope this is now clear.


Nope. 2 items are each available from 3 suppliers. That's six
possibilities, not nine:

Item 1, Supplier 1
Item 1, Supplier 2
Item 1, Supplier 3
Item 2, Supplier 1
Item 2, Supplier 2
Item 2, Supplier 3

Take this as constructive criticism, not just ankle biting. It would
seem there's a great deal of confusion in your design. If you're having
a hard time nailing the requirements, the code is doomed to failure.

Forget about the implementation for now and concentrate solely upon the
use cases for your application. Once the use cases are laid out you can
design the application specs. Coding should be the next step in that
process, not the first.

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

http://code.acadx.com
(Pull the pin to reply)
Nov 15 '05 #9
"Frank Oquendo" <fr*******@acadx.com> wrote in
news:OE**************@TK2MSFTNGP12.phx.gbl:
tony collier wrote:
= 3^2 = 9 combinations in all possible orders.

hope this is now clear.


Nope. 2 items are each available from 3 suppliers. That's six
possibilities, not nine:

Item 1, Supplier 1
Item 1, Supplier 2
Item 1, Supplier 3
Item 2, Supplier 1
Item 2, Supplier 2
Item 2, Supplier 3

Take this as constructive criticism, not just ankle biting. It would
seem there's a great deal of confusion in your design. If you're
having a hard time nailing the requirements, the code is doomed to
failure.

Forget about the implementation for now and concentrate solely upon
the use cases for your application. Once the use cases are laid out
you can design the application specs. Coding should be the next step
in that process, not the first.


Maybe i just haven't explained it very well so far. In your example
above you have understood me to want 1 item. This is not what i want. I
want both items. in my previous list when i wrote things like

a,a , this meant that i was pricing the cost of buying item 1 from
supplier a AND item 2 from supplier a. so

a,b means buying item 1 from supplier a and item 2 from supplier b.

b,a means buying item1 from supplier b and and item 2 from supplier a

and so on. ( therefore a,b doesn't equal b,a incidentally)
Nov 15 '05 #10
I'm not sure why you need this, but don't store it, just calculate it as you need it, that way you need to store very little data.

--
Michael Culley
"tony collier" <me*****@hotmail.com> wrote in message news:Xn*******************************@140.99.99.1 30...
"Frank Oquendo" <fr*******@acadx.com> wrote in
news:OE**************@TK2MSFTNGP12.phx.gbl:
tony collier wrote:
= 3^2 = 9 combinations in all possible orders.

hope this is now clear.


Nope. 2 items are each available from 3 suppliers. That's six
possibilities, not nine:

Item 1, Supplier 1
Item 1, Supplier 2
Item 1, Supplier 3
Item 2, Supplier 1
Item 2, Supplier 2
Item 2, Supplier 3

Take this as constructive criticism, not just ankle biting. It would
seem there's a great deal of confusion in your design. If you're
having a hard time nailing the requirements, the code is doomed to
failure.

Forget about the implementation for now and concentrate solely upon
the use cases for your application. Once the use cases are laid out
you can design the application specs. Coding should be the next step
in that process, not the first.


Maybe i just haven't explained it very well so far. In your example
above you have understood me to want 1 item. This is not what i want. I
want both items. in my previous list when i wrote things like

a,a , this meant that i was pricing the cost of buying item 1 from
supplier a AND item 2 from supplier a. so

a,b means buying item 1 from supplier a and item 2 from supplier b.

b,a means buying item1 from supplier b and and item 2 from supplier a

and so on. ( therefore a,b doesn't equal b,a incidentally)

Nov 15 '05 #11
tony collier wrote:
a,a , this meant that i was pricing the cost of buying item 1 from
supplier a AND item 2 from supplier a. so

a,b means buying item 1 from supplier a and item 2 from supplier b.

b,a means buying item1 from supplier b and and item 2 from supplier a

and so on. ( therefore a,b doesn't equal b,a incidentally)


That's not a function of the data. Simply store the items, the suppliers
and relevant pricing. Let the user choose what he wants instead of
trying to preconceive every possible permutation.

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

http://code.acadx.com
(Pull the pin to reply)
Nov 15 '05 #12
X^Y - As far as the explaination is concern methematically what Tony said is
correct...

in the same time if a one supplier cannot same item again then it become

x!
_
(x-1)!

Nirosh.

"Michael Culley" <mc*****@NOSPAMoptushome.com.au> wrote in message
news:#E**************@TK2MSFTNGP12.phx.gbl...
I'm not sure why you need this, but don't store it, just calculate it as you need it, that way you need to store very little data.
--
Michael Culley
"tony collier" <me*****@hotmail.com> wrote in message

news:Xn*******************************@140.99.99.1 30...
"Frank Oquendo" <fr*******@acadx.com> wrote in
news:OE**************@TK2MSFTNGP12.phx.gbl:
tony collier wrote:

> = 3^2 = 9 combinations in all possible orders.
>
> hope this is now clear.

Nope. 2 items are each available from 3 suppliers. That's six
possibilities, not nine:

Item 1, Supplier 1
Item 1, Supplier 2
Item 1, Supplier 3
Item 2, Supplier 1
Item 2, Supplier 2
Item 2, Supplier 3

Take this as constructive criticism, not just ankle biting. It would
seem there's a great deal of confusion in your design. If you're
having a hard time nailing the requirements, the code is doomed to
failure.

Forget about the implementation for now and concentrate solely upon
the use cases for your application. Once the use cases are laid out
you can design the application specs. Coding should be the next step
in that process, not the first.


Maybe i just haven't explained it very well so far. In your example
above you have understood me to want 1 item. This is not what i want. I
want both items. in my previous list when i wrote things like

a,a , this meant that i was pricing the cost of buying item 1 from
supplier a AND item 2 from supplier a. so

a,b means buying item 1 from supplier a and item 2 from supplier b.

b,a means buying item1 from supplier b and and item 2 from supplier a

and so on. ( therefore a,b doesn't equal b,a incidentally)


Nov 15 '05 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Evan Dekker | last post by:
hi all im not why this code doesn't work: ///////// import java.applet.*; import java.awt.*; public class TestApplet extends Applet { public void init() {
5
by: Maggie | last post by:
Hi, can someone tell me how to make this table in css <table> <tr> <td></td> </tr> <tr> <td> <table> <tr>
1
by: nospam | last post by:
All I am trying to achieve the following: Main window page's asp code writes the following line to launch a popup window (note the IFRAME has to be in the popup window, it cannot be in the...
9
by: Marco Jez | last post by:
Is it legal, in a class template's member function, to instantiate the same class template but with a different type as argument? The following code is very simple and I'd expect it to compile, but...
4
by: groleo | last post by:
Hi. I'm trying to port a piece of code, written for win32, that uses the finddata_t structure. Is there an equivalent , or a work-around, that implement finddata_t on *nix platforms?
113
by: Bonj | last post by:
I was in need of an encryption algorithm to the following requirements: 1) Must be capable of encrypting strings to a byte array, and decyrpting back again to the same string 2) Must have the same...
13
by: Giggle Girl | last post by:
My pages need to unfold gracefully even if Javascript is disabled, but I can't get this to work? Please help, Javascript Gurus!! <noscript> document.write('<span class=warning><b>Warning</b>:...
11
by: tlyczko | last post by:
Hello Rob B posted this wonderful code in another thread, http://groups.google.com/group/comp.lang.javascript/browse_thread/thread/c84d8538025980dd/6ead9d5e61be85f0#6ead9d5e61be85f0 I could not...
14
by: mathieu | last post by:
I would like to know if the following operation on s2 is legal or not. And if not what should I do instead (my data member are declared at the begining of the struct). I am pretty sure this is...
4
by: Anil Gupte | last post by:
A friend of mine is having this problem on his machine - it works fine on my machine. The above message appears when he tries to inset the "Microsoft Internet Transfer Control" (Inet) into a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.