Get Combos

1. Senior Member
Join Date
Dec 1969
Posts
1,849

## Get Combos

Allright, playing off my "crappy bank" question yesterday, have a little better idea on what the client wants to acomplish...<BR><BR>Have an array,<BR>1, 2, 3, 4, 5<BR><BR>Need to create a system to find all combinations within this array.<BR><BR>Say, I need an 8<BR><BR>this "loop" or function needs to find 5 and 3<BR><BR>it will test 1 + 2, 1 + 3, 1 + 4, 1 + 5, 2 + 3, 2 + 4, 2 + 5, 3 + 4, 3 + 5 * FOUND * <BR><BR>Or continue to search until it reaches all combinations, or a match is found!<BR><BR>-- Whol

2. Senior Member
Join Date
Dec 1969
Posts
1,570

## RE: Get Combos

i don&#039;t know if anyone is going to just give you an answer, have you got any code to show that you have tried working this out???

3. Senior Member
Join Date
Dec 1969
Posts
1,849

## Still in concept

The idea is to get all possible combinations. I don&#039;t want code. I want algorythm. How would you do it... I am putting pen to paper right now to figure it out. <BR><BR>I did it before, (Years ago) and can&#039;t quite remember how exactly I did it...<BR><BR>-- Whol

4. Senior Member
Join Date
Dec 1969
Posts
135

## almost sounds like homework.. :)

This almost sounds like homework.. but have you got any code to post at all?

5. Senior Member
Join Date
Dec 1969
Posts
1,849

## Its not.

I am trying to re-write this nasty program for a banking application. Currently takes 12 to 24 hours to process 200 records. (This is a re-post from yesterday, with more information)<BR><BR>

6. Senior Member
Join Date
Dec 1969
Posts
2,854

## RE: Its not.

Function getCombos(int)<BR> for i = 1 to int-1<BR> Response.Write i "+" (int-1)-i<BR> next<BR>End Function

7. Senior Member
Join Date
Dec 1969
Posts
2,854

## Sorry, mistake

Function getCombos(int)<BR>for i = 1 to int-1<BR>Response.Write i "+" int-i<BR>next<BR>End Function

8. Senior Member
Join Date
Dec 1969
Posts
2,854

Sorry, Last time<BR><BR>&#060;%<BR>Function getCombos(int) <BR>for i = 1 to int-1 <BR>getCombos = getCombos & i & "+" & int-i & "<BR>"<BR>next <BR>End Function <BR><BR>Response.Write getCombos(15)<BR>%&#062;<BR><BR>And that should print out all your combo&#039;s

9. oli
Senior Member
Join Date
Dec 1969
Posts
3,961

## RE: Get Combos

I don&#039;t know why, but I&#039;m thinking binary. I&#039;ll get back to you.

10. Senior Member
Join Date
Dec 1969
Posts
2,854