Jump to content

Array of combinations

Go to solution Solved by jchd,

Recommended Posts

Hi all,

I have 2 lists of materials with a list of basic material and another list of secondary material.

And I want generate an array with the list of combinations. I looked _ArrayCombinations() function but it doesn't work properly...

```Local \$aArray[10] = ["H", "Li", "Na", "K", "Rb", "Cs", "Ti/B", "Zr/Si", "Hf/As", "Rf/Sb"]

Local \$aArrayCombo = _ArrayCombinations(\$aArray, 7, ",")
_ArrayToString(\$aArrayCombo, ',')
_ArrayDisplay(\$aArrayCombo)```

"H", "Li", "Na", "K", "Rb" and "Cs" are basics materials, so they must be in each combinations. And other "groups" only one of two.

For example:

"H", "Li", "Na", "K", "Rb", "Cs", "Ti", "Zr", "As", "Sb"

"H", "Li", "Na", "K", "Rb", "Cs", "B", "Zr", "As", "Rf"

Qui ose gagneWho Dares Win[left]CyberExploit[/left]

Share on other sites

Something like this ?

```Local \$sBase = "H,Li,Na,K,Rb,Cs,"
Local \$aSalt = ["Ti", "B", "Zr", "Si", "Hf", "As", "Rf", "Sb"]

Local \$aCombo = _ArrayCombinations(\$aSalt, 2, ",")
_ArrayDelete(\$aCombo, 0)
For \$i = 0 To UBound(\$aCombo) - 1
\$aCombo[\$i] = '"' & StringReplace(\$sBase & \$aCombo[\$i], ',', '", "') & '"'
Next
_ArrayDisplay(\$aCombo)```

BTW do you really have a significant physical stock of Rutherfordium, or do you produce it on demand in your microwave oven?

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share on other sites
Posted (edited)

On the periodic table of elements, we have basic elements that cannot be coupled. But these elements can be combined with most other elements of the table. I have a table in Excel with characteristics for each element. And columns of calculations on each combination.

And in the code that you note, it doesn't include every subgroup.

The basic elements should always be in each list and then 1 element from each group.

In my example, the series that I note "Ti/B", "Zr/Si", "Hf/As", "Rf/Sb" means that in each list you can have only Ti OR B but not both. But one element of each group.

Edited by jerem488

Qui ose gagneWho Dares Win[left]CyberExploit[/left]

Share on other sites
• Solution

Even if I strongly suspect this has nothing to do with chemistry and all to do with some game,

```Local \$sBase = "H,Li,Na,K,Rb,Cs"
Local \$aSalt = [["Ti", "B"], ["Zr", "Si"], ["Hf", "As"], ["Rf", "Sb"]]
Local \$aCombo[2 ^ UBound(\$aSalt)]

For \$i = 0 To UBound(\$aCombo) - 1
For \$j = 0 To UBound(\$aSalt) - 1
\$aCombo[\$i] &= "," & \$aSalt[\$j][BitAND(BitShift(\$i, \$j), 1)]
Next
\$aCombo[\$i] = '"' & StringReplace(\$sBase & \$aCombo[\$i], ',', '", "') & '"'
Next

_ArrayDisplay(\$aCombo)```

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share on other sites

Thanks a lot !

As soon as my program will be completely finished I will gladly put it in the examples of this site

Qui ose gagneWho Dares Win[left]CyberExploit[/left]

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
• Recently Browsing   0 members

No registered users viewing this page.

×

• Wiki
• AutoIt Resources

• FAQ
×
• Create New...