Combinations of sets

From: Jostein (jostein.solstad_at_gmail.com)
Date: 10/19/04


Date: 19 Oct 2004 08:14:45 -0700

Hi.

Anyone know how i can write this code if i dont know the number of
sets.
In my working example each set will represent a loop. Sets could be
[Blue,Red] [Large,Small,Very Small] [Oval,Square]. The below would
list all the combinations (Blue-Large-Oval is one) correctly. Prolbem
is that i cant say there is 3 sets, there could be 4,5 or whatever.

for i1 := 0 to AttrArray[0].Count-1 do
  begin
    for i2 := 0 to AttrArray[1].Count-1 do
    begin
      for i3 := 0 to AttrArray[2].Count-1 do
      begin
        combs := AttrArray[0].Strings[i1].ToString + ' ' +
AttrArray[1].Strings[i2].ToString + ' ' +
AttrArray[2].Strings[i3].ToString;
        Response.Write(combs+'<br>');
      end;
    end
  end;

Thank you for any help. Im stuck on this :(



Relevant Pages

  • Re: I made a boo boo...
    ... > I created a do loop that i cant get out of.how can i crash the ... > program?i dont want to lose data and because im on a computer in Uni, ...
    (microsoft.public.vb.general.discussion)
  • Calculating an average [was Re: Summary of loops]
    ... Been stuck doing this program and ... > cant seem to debug the errors! ... > How do I calculate the totals of the computation in a loop ...
    (comp.lang.java.help)
  • I made a boo boo...
    ... I created a do loop that i cant get out of.how can i crash the ... program?i dont want to lose data and because im on a computer in Uni, ...
    (microsoft.public.vb.general.discussion)
  • Help with COUNTIF formula
    ... I thought this would be a fairly simple formula but just dont seem to ... be able to get the right syntax. ... Any advice or help would be appreciated as completely stuck and cant ...
    (microsoft.public.excel.misc)
  • Re: break statement
    ... possible setting a boolean flag" ... > NO GOTO PLEASE ... > dont achieve things any better then using while/loops/fors.... ... > inner loop and a flag to get off the outer one or yet anothe break. ...
    (microsoft.public.dotnet.framework)