| | |
Algorithm HELP!
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Nov 2007
Posts: 6
Reputation:
Solved Threads: 0
Hi guys. Im a student and i have a problem in finding the right procedure to solve my problem. Giving a set of numbers that will find their combination for a given value. For example 1st digit will be the size and the 2nd digit will be the qty.:
Size qty
10 10
20 10
30 10
40 10
50 10
60 10
70 10
80 10
90 10
100 10
the problem will be, I’ll find the 1 to 5 combinations to have a sum of 100:
the answers will be like the following:
100 10
90+10 10
80+20 10
70+30 10
40+60 10
50+50 5
the answers is only 1 and 2 combinations. I would like to create a procedure that will compute up to 5 combinations and will check the qty is still available for combining into another size. the problem is my function becomes very slow when im trying to manipulate it using string handling functions. Any input that will enlighten my mind will be a great help. Thanks in advance.
Size qty
10 10
20 10
30 10
40 10
50 10
60 10
70 10
80 10
90 10
100 10
the problem will be, I’ll find the 1 to 5 combinations to have a sum of 100:
the answers will be like the following:
100 10
90+10 10
80+20 10
70+30 10
40+60 10
50+50 5
the answers is only 1 and 2 combinations. I would like to create a procedure that will compute up to 5 combinations and will check the qty is still available for combining into another size. the problem is my function becomes very slow when im trying to manipulate it using string handling functions. Any input that will enlighten my mind will be a great help. Thanks in advance.
•
•
Join Date: Aug 2007
Posts: 47
Reputation:
Solved Threads: 0
Please specify the total number of sequence (ex.. 1 to totalnumberofsequence) if the total number of sequence is base on the input try this systax
Dim input as integer
dim algo as integer
dim cnt as integer
dim combo as integer
'no of sequence
algo = 0
for cnt = 1 to input
algo = algo + input
? algo, input
next cnt
'finding the combination
cnt = 0
combo = algo
algo = algo - input
while combo = algo
cnt = cnt + 1
combo = (algo + input)
input = input + input
loop
' cnt is the total number of combination
Dim input as integer
dim algo as integer
dim cnt as integer
dim combo as integer
'no of sequence
algo = 0
for cnt = 1 to input
algo = algo + input
? algo, input
next cnt
'finding the combination
cnt = 0
combo = algo
algo = algo - input
while combo = algo
cnt = cnt + 1
combo = (algo + input)
input = input + input
loop
' cnt is the total number of combination
•
•
Join Date: Nov 2007
Posts: 6
Reputation:
Solved Threads: 0
thanks for the input locsin. i already created a function that will loop (1 to 5 comb) to combine the given set of numbers. the problem is im having trouble with getting the difference of the qty. for example:
---------------------------------------
combination requirement= 400
size 100+90+80+70+60
qty respectively 10,9,8,7,6
ANS:
6 set for 100+90+80+70+60
qty respectively 4,3,2,1,0
---------------------------------------
this sample is easy to compute coz of theres no redundant size have been combined. the next example will be a little bit of complicated:
----------------------------------------
combination requirement= 400
size 100+100+90+80+30
qty respectively 10,10,11,12,13
ANS:
5 sets for 100+100+90+80+30
qty respectively 0,0,6,7,8
------------------------------------------
the problem is, am having trouble with getting the difference of the qty. for now, im using a string handling function for computation of combinations but reducing the qty is my main problem using that function( ex. sorting the qty and determining the lowest qty to be the set size). can someone suggest an idea that will help me to solve my problem? thanks all.
---------------------------------------
combination requirement= 400
size 100+90+80+70+60
qty respectively 10,9,8,7,6
ANS:
6 set for 100+90+80+70+60
qty respectively 4,3,2,1,0
---------------------------------------
this sample is easy to compute coz of theres no redundant size have been combined. the next example will be a little bit of complicated:
----------------------------------------
combination requirement= 400
size 100+100+90+80+30
qty respectively 10,10,11,12,13
ANS:
5 sets for 100+100+90+80+30
qty respectively 0,0,6,7,8
------------------------------------------
the problem is, am having trouble with getting the difference of the qty. for now, im using a string handling function for computation of combinations but reducing the qty is my main problem using that function( ex. sorting the qty and determining the lowest qty to be the set size). can someone suggest an idea that will help me to solve my problem? thanks all.
![]() |
Similar Threads
- Help with LR parser algorithm (Java)
- round robin algorithm (Computer Science)
- Round Robin Algorithm Simulation (C++)
- Eigenface Algorithm (Computer Science)
- Algorithm for checking contiguous blocks (C)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: Media Control Interface (MCI) vb script help
- Next Thread: help me out...
| Thread Tools | Search this Thread |
* 6 429 2007 access activex add age append application basic beginner birth bmp calculator cd cells.find click client code college column component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report retrieve save search sendbyte sites sort sql sql2008 sqlserver subroutine table tags textbox time urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows





