Big data elaboration

Then it’s not clear what you are trying to do.

The numbers don’t repeat in the numerator, and they don’t repeat in the denominator. But, I thought that you wanted all of the numbers to occur exactly once in the numerator and exactly once in the denominator. That is what my previous code does.

If you don’t want the numbers to repeat between the numerator and denominator at all then you can set the loop indices like this:

For A=0 To ArraiIngranaggiRuotaA.LastIndex-5
  For C=A+1 To ArraiIngranaggiRuotaB.LastIndex-4
    For E=C+1 To ArraiIngranaggiRuotaC.LastIndex-3
      For B=E+1 To ArraiIngranaggiRuotaD.LastIndex-2
        For D=B+1 To ArraiIngranaggiRuotaE.LastIndex-1
          For F=D+1 To ArraiIngranaggiRuotaF.LastIndex
            
            ace = ArraiIngranaggiRuotaA(a) * ArraiIngranaggiRuotaC(c) * ArraiIngranaggiRuotaE(e)
            bdf = ArraiIngranaggiRuotaB(b) * ArraiIngranaggiRuotaD(d) * ArraiIngranaggiRuotaF(f)
            
            R = ace / bdf
            VisualizzaStringa="("+ArraiIngranaggiRuotaA(A).ToText+"x" +ArraiIngranaggiRuotaC(C).ToText+"x"+ArraiIngranaggiRuotaE(E).ToText + " / " +ArraiIngranaggiRuotaB(B).ToText+"x"+ArraiIngranaggiRuotaD(D).ToText+"x"+ArraiIngranaggiRuotaF(F).ToText+")"
            
            output = str(ArraiIngranaggiRuotaA(A))  + "**" + str(ArraiIngranaggiRuotaB(B))  + "**" + str(ArraiIngranaggiRuotaC(C))  + "**" + str(ArraiIngranaggiRuotaD(D))  + "**" + str(ArraiIngranaggiRuotaE(E))  + "**" + str(ArraiIngranaggiRuotaF(F)) + "**" +"-------"+ "**" + VisualizzaStringa + "**" +" ------------"+"**"+ str(R)  
            t.writeline(output)
            
          Next
        Next
      Next
    Next
  Next
  
Next

If that doesn’t work for you, then you need to explain exactly how you want the numerator and denominator numbers to vary.

This is already much better, there are many combinations without repeating numbers, BUT, missing combinations… after the last line there would still be:
48x100x56 or 48x72x66 … or … 72x56x100

The numbers are arranged in order of increasing index values. So, the value
48x100x56 is present as 48x56x100
and
48x72x66 is present as 48x66x72
and so on.

100 or 72 in the numerator never sample

I would need all the possible combinations without repetitions, both in the numerator and in the denominator … sorry, but I don’t know how to explain it to you.
I have to get all the combinations I can with the values inside the array…in the result I posted of your code, it shows that for example 72 or 100 never end up in the numerator, but always remain in the denominator.

When I run the code I get 72 and 100 in the numerator. Here is a partial list:
(40 x 72 x 100) / (40 x 44 x 56)
(40 x 72 x 100) / (40 x 44 x 64)
(40 x 72 x 100) / (40 x 44 x 66)
(40 x 72 x 100) / (40 x 44 x 72)
(40 x 72 x 100) / (40 x 44 x 100)
(40 x 72 x 100) / (40 x 48 x 56)
(40 x 72 x 100) / (40 x 48 x 64)
(40 x 72 x 100) / (40 x 48 x 66)
(40 x 72 x 100) / (40 x 48 x 72)
(40 x 72 x 100) / (40 x 48 x 100)
(40 x 72 x 100) / (40 x 56 x 64)
(40 x 72 x 100) / (40 x 56 x 66)
(40 x 72 x 100) / (40 x 56 x 72)
(40 x 72 x 100) / (40 x 56 x 100)
(40 x 72 x 100) / (40 x 64 x 66)
(40 x 72 x 100) / (40 x 64 x 72)
(40 x 72 x 100) / (40 x 64 x 100)
(40 x 72 x 100) / (40 x 66 x 72)
(40 x 72 x 100) / (40 x 66 x 100)
(40 x 72 x 100) / (40 x 72 x 100)
(40 x 72 x 100) / (44 x 48 x 56)
(40 x 72 x 100) / (44 x 48 x 64)
(40 x 72 x 100) / (44 x 48 x 66)
(40 x 72 x 100) / (44 x 48 x 72)
(40 x 72 x 100) / (44 x 48 x 100)
(40 x 72 x 100) / (44 x 56 x 64)
(40 x 72 x 100) / (44 x 56 x 66)
(40 x 72 x 100) / (44 x 56 x 72)
(40 x 72 x 100) / (44 x 56 x 100)
(40 x 72 x 100) / (44 x 64 x 66)

The complete list is too long to post here.

then I can ask you to share your listing again, there must be something wrong not mine, because I don’t get to those lines.

Thanks so much for your help

This is the code I used to output the list:

Dim x() as integer=array(40,44,48,56,64,66,72,100)
'Numerator loops
for a as Integer = 0 to x.Ubound-2
  for c as Integer = a+1 to x.Ubound-1
    for e as Integer = c+1 to x.Ubound
      'denominator loops
      for b as Integer = 0 to x.Ubound-2
        for d as Integer = b+1 to x.Ubound-1
          for f as Integer = d+1 to x.Ubound
            'Output this combination to text field
            tf1.AppendText "("+str(x(a))+" x "+str(x(c))+" x "+str(x(e))+") / ("+str(x(b))+" x "+str(x(d))+" x "+str(x(f))+")"+EndOfLine
          next
        next
      next
    next
  next
next
''OUTPUT FORMULA:   R= (A*C*E)/(B*D*F)
dim start as integer
start = System.Microseconds
var output as string
Var file As FolderItem = SpecialFolder.Desktop.Child("testOutPut.csv")
Var t As TextOutputStream = TextOutputStream.Create(file)


Dim x() as integer=array(40,44,48,56,64,66,72,100)
'Numerator loops
for a as Integer = 0 to x.Ubound-2
  for c as Integer = a+1 to x.Ubound-1
    for e as Integer = c+1 to x.Ubound
      'denominator loops
      for b as Integer = 0 to x.Ubound-2
        for d as Integer = b+1 to x.Ubound-1
          for f as Integer = d+1 to x.Ubound
            'Output this combination to text field
            t.WriteLine "("+str(x(a))+" x "+str(x(c))+" x "+str(x(e))+") / ("+str(x(b))+" x "+str(x(d))+" x "+str(x(f))+")"+EndOfLine
          next
        next
      next
    next
  next
next


t.close
MessageBox str((System.Microseconds - start) / 1000000) + " seconds"

I had to replace just a few things related to the file, maybe it changes according to the version of Xojo.
But the result still doesn’t work… there are equal values ​​in the list of results, for example, in the 1st line the numbers 40 - 44 - 48 are repeated, in the 3rd line 40 -44 is repeated, in the 5th line 40-44

49 line are repeated on 44-48

Those lines in the numerator are repeating, because the lines in the denominator are changing, but the value of the fraction is different for each line.I thought that is what you asked for.
I had earlier set up the loops so that numbers in the numerator could not appear in the denominator, but you said that was wrong.

Excuse me I need to have all possible combinations, without repetition, unless the same number is inserted into the array several times. I’m testing the various codes from time to time, but if I wrote that it was wrong it was because in the output table, there was something wrong.


Among all the codes you sent me, this is the one that comes closest … but if you notice well in the table, some values are missing in the numerator such as 72 and 100

''OUTPUT FORMULA:   R= (A*C*E)/(B*D*F)
dim start as integer
start = System.Microseconds
var output as string
Dim ArrayIngranaggi() as integer=array(40,44,48,56,64,66,72,100)
Dim ArraiIngranaggiRuotaA() as integer=ArrayIngranaggi()
Dim ArraiIngranaggiRuotaB() as integer=ArrayIngranaggi()
Dim ArraiIngranaggiRuotaC() as integer=ArrayIngranaggi()
Dim ArraiIngranaggiRuotaD() as integer=ArrayIngranaggi()
Dim ArraiIngranaggiRuotaE() as integer=ArrayIngranaggi()
Dim ArraiIngranaggiRuotaF() as integer=ArrayIngranaggi()

Dim VisualizzaStringa as string

Var file As FolderItem = SpecialFolder.Desktop.Child("testOutPut.csv")
Var t As TextOutputStream = TextOutputStream.Create(file)


Dim R as currency
Dim ace,bdf as integer
Dim A,B,C,D,E,F as integer

For A=0 To ArraiIngranaggiRuotaA.LastIndex-5
  For C=A+1 To ArraiIngranaggiRuotaB.LastIndex-4
    For E=C+1 To ArraiIngranaggiRuotaC.LastIndex-3
      For B=E+1 To ArraiIngranaggiRuotaD.LastIndex-2
        For D=B+1 To ArraiIngranaggiRuotaE.LastIndex-1
          For F=D+1 To ArraiIngranaggiRuotaF.LastIndex
            
            ace = ArraiIngranaggiRuotaA(a) * ArraiIngranaggiRuotaC(c) * ArraiIngranaggiRuotaE(e)
            bdf = ArraiIngranaggiRuotaB(b) * ArraiIngranaggiRuotaD(d) * ArraiIngranaggiRuotaF(f)
            
            R = ace / bdf
            VisualizzaStringa="("+ArraiIngranaggiRuotaA(A).ToText+"x" +ArraiIngranaggiRuotaC(C).ToText+"x"+ArraiIngranaggiRuotaE(E).ToText + " / " +ArraiIngranaggiRuotaB(B).ToText+"x"+ArraiIngranaggiRuotaD(D).ToText+"x"+ArraiIngranaggiRuotaF(F).ToText+")"
            
            output = str(ArraiIngranaggiRuotaA(A))  + "**" + str(ArraiIngranaggiRuotaB(B))  + "**" + str(ArraiIngranaggiRuotaC(C))  + "**" + str(ArraiIngranaggiRuotaD(D))  + "**" + str(ArraiIngranaggiRuotaE(E))  + "**" + str(ArraiIngranaggiRuotaF(F)) + "**" +"-------"+ "**" + VisualizzaStringa + "**" +" ------------"+"**"+ str(R)  
            t.writeline(output)
            
          Next
        Next
      Next
    Next
  Next
  
Next


t.close
MessageBox str((System.Microseconds - start) / 1000000) + " seconds"

It might be easier if we could look at a smaller version of the of the problem. For example, let’s consider a simpler fraction: (A * C) / (B * D), and an array with only 5 elements: (40,44,48,56,64). Then the different loop parameters would produce a much smaller output list which would be easier analyze.

Look, in a very improvised way, I tried to add lines to reverse denominator with numerator, and I got a much more complete list of combinations…

''OUTPUT FORMULA:   R= (A*C*E)/(B*D*F)
dim start as integer
start = System.Microseconds
var output as string
Dim ArrayIngranaggi() as integer=array(40,44,48,56,64,66,72,100)
Dim ArraiIngranaggiRuotaA() as integer=ArrayIngranaggi()
Dim ArraiIngranaggiRuotaB() as integer=ArrayIngranaggi()
Dim ArraiIngranaggiRuotaC() as integer=ArrayIngranaggi()
Dim ArraiIngranaggiRuotaD() as integer=ArrayIngranaggi()
Dim ArraiIngranaggiRuotaE() as integer=ArrayIngranaggi()
Dim ArraiIngranaggiRuotaF() as integer=ArrayIngranaggi()

Dim VisualizzaStringa as string

Var file As FolderItem = SpecialFolder.Desktop.Child("testOutPut.csv")
Var t As TextOutputStream = TextOutputStream.Create(file)


Dim R as currency
Dim ace,bdf as integer
Dim A,B,C,D,E,F as integer

For A=0 To ArraiIngranaggiRuotaA.LastIndex-5
  For C=A+1 To ArraiIngranaggiRuotaB.LastIndex-4
    For E=C+1 To ArraiIngranaggiRuotaC.LastIndex-3
      For B=E+1 To ArraiIngranaggiRuotaD.LastIndex-2
        For D=B+1 To ArraiIngranaggiRuotaE.LastIndex-1
          For F=D+1 To ArraiIngranaggiRuotaF.LastIndex
            
            ace = ArraiIngranaggiRuotaA(a) * ArraiIngranaggiRuotaC(c) * ArraiIngranaggiRuotaE(e)
            bdf = ArraiIngranaggiRuotaB(b) * ArraiIngranaggiRuotaD(d) * ArraiIngranaggiRuotaF(f)
            
            R = ace / bdf
            VisualizzaStringa="("+ArraiIngranaggiRuotaA(A).ToText+"x" +ArraiIngranaggiRuotaC(C).ToText+"x"+ArraiIngranaggiRuotaE(E).ToText + " / " +ArraiIngranaggiRuotaB(B).ToText+"x"+ArraiIngranaggiRuotaD(D).ToText+"x"+ArraiIngranaggiRuotaF(F).ToText+")"
            
            output = str(ArraiIngranaggiRuotaA(A))  + "**" + str(ArraiIngranaggiRuotaB(B))  + "**" + str(ArraiIngranaggiRuotaC(C))  + "**" + str(ArraiIngranaggiRuotaD(D))  + "**" + str(ArraiIngranaggiRuotaE(E))  + "**" + str(ArraiIngranaggiRuotaF(F)) + "**" +"-------"+ "**" + VisualizzaStringa + "**" +" ------------"+"**"+ str(R)  
            t.writeline(output)
            
          Next
        Next
      Next
    Next
  Next
  
Next



For F=0 To ArraiIngranaggiRuotaF.LastIndex-5
  For E=F+1 To ArraiIngranaggiRuotaE.LastIndex-4
    For D=E+1 To ArraiIngranaggiRuotaD.LastIndex-3
      For C=D+1 To ArraiIngranaggiRuotaC.LastIndex-2
        For B=C+1 To ArraiIngranaggiRuotaB.LastIndex-1
          For A=B+1 To ArraiIngranaggiRuotaA.LastIndex
            
            ace = ArraiIngranaggiRuotaA(a) * ArraiIngranaggiRuotaC(c) * ArraiIngranaggiRuotaE(e)
            bdf = ArraiIngranaggiRuotaB(b) * ArraiIngranaggiRuotaD(d) * ArraiIngranaggiRuotaF(f)
            
            R = ace / bdf
            VisualizzaStringa="("+ArraiIngranaggiRuotaA(A).ToText+"x" +ArraiIngranaggiRuotaC(C).ToText+"x"+ArraiIngranaggiRuotaE(E).ToText + " / " +ArraiIngranaggiRuotaB(B).ToText+"x"+ArraiIngranaggiRuotaD(D).ToText+"x"+ArraiIngranaggiRuotaF(F).ToText+")"
            
            output = str(ArraiIngranaggiRuotaA(A))  + "**" + str(ArraiIngranaggiRuotaB(B))  + "**" + str(ArraiIngranaggiRuotaC(C))  + "**" + str(ArraiIngranaggiRuotaD(D))  + "**" + str(ArraiIngranaggiRuotaE(E))  + "**" + str(ArraiIngranaggiRuotaF(F)) + "**" +"-------"+ "**" + VisualizzaStringa + "**" +" ------------"+"**"+ str(R)  
            t.writeline(output)
            
          Next
        Next
      Next
    Next
  Next
  
Next





t.close
MessageBox str((System.Microseconds - start) / 1000000) + " seconds"

Now I’m not sure if that’s all the combinations I can get, but there’s definitely a lot more than before…not an easy problem to fix.

Okay, I think I finally understand what you’re trying to do. This is neither a permutation nor combination situation, but a combination of both. I doubt that there is any way to do this with just loop parameters. It will also require some conditional tests. Here is some new code that you can test:

Dim x() as integer=array(40,44,48,56,64,66,72,100)
efOut.AppendText "a  c  e  b  d  f"+EndOfLine
'Numerator loops
for a as Integer = 0 to x.Ubound-2
  for c as Integer = a+1 to x.Ubound-1
    for e as Integer = c+1 to x.Ubound
      'denominator loops
      for b as Integer = 0 to x.Ubound-2
        if b=a or b=c or b=e then Continue
        for d as Integer = b+1 to x.Ubound-1
          if d=a or d=c or d=e then Continue
          for f as Integer = d+1 to x.Ubound
            if f=a or f=c or f=e then Continue
            'Append this combination to output
            efOut.AppendText "("+str(x(a))+" x "+str(x(c))+" x "+str(x(e))+") / ("+str(x(b))+" x "+str(x(d))+" x "+str(x(f))+")"+EndOfLine
          next
        next
      next
    next
  next
next

Here is a link to the output file produced by this code.
http://electronbunker.ca/XojoProjects/acebdf_List.txt

Im still mildly curious about why this is wanted. (The real-world scenario)

Yes Robert, now it’s much much better, I have many combinations of numbers … it’s really a problem to understand if they are all there, but it’s an excellent basis for having results. Thank you very much for your advice. Your code is very accurate, compact and fast. I’m really happy.

I’m building a mechanical tool for making gears. I already own some gears and I wanted to understand with the ones I have, how many combinations I can make (2 gears, 4 gears with two in pairs, and 6 gears with 2 pairs) … with the 6 gears I get the maximum ratios I can have with my gears. This ratio combined with that of my mechanical divider, will allow me to carve the teeth. Now I have to try the results to understand if everything works.

Hello federico, I remember posting, some time ago, a couple of algorithms for computing permutations without repetition. See if they might be useful, you can find them in the forum at this link Looking for unique number of Base X - #5 by Andrew_Lambert

Heap’s algorithm generates n permutations from a set of n numbers. It’s not applicable in this situation.