jerem488 Posted May 8, 2022 Share Posted May 8, 2022 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] Link to comment Share on other sites More sharing options...
jchd Posted May 8, 2022 Share Posted May 8, 2022 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? Earthshine 1 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 hereRegExp tutorial: enough to get startedPCRE 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) Link to comment Share on other sites More sharing options...
jerem488 Posted May 10, 2022 Author Share Posted May 10, 2022 (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 May 10, 2022 by jerem488 Qui ose gagneWho Dares Win[left]CyberExploit[/left] Link to comment Share on other sites More sharing options...
Solution jchd Posted May 10, 2022 Solution Share Posted May 10, 2022 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 hereRegExp tutorial: enough to get startedPCRE 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) Link to comment Share on other sites More sharing options...
jerem488 Posted May 10, 2022 Author Share Posted May 10, 2022 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] Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now