I have a function called ModelsProduct in which I am generating all possible combinations of "+/-" and "a,b,c,d,e". In the below code #producemodelsOne
modelsStepOne selects the all 8 combinations of +/-
modelsStepTwo selects the first value of list i-e a
modelsStepThree selects its first value of list i-e ('a','a')
modelsStepFour selects its first value of list i-e ('d','d')
modelsStepFive selects its first value of list i-e ('e','e')
which makes a combination of [+,+,+,+,+,+,+,+,a,a,a,d,d,e,e] and iterates so on for all possible combinations.
Following is the Output when you print it.
print (modelsOne[0])
print (modelsOne[1])
('+', '+', '+', '+', '+', '+', '+', '+', 'a', 'a', 'a', 'd', 'd', 'e', 'e')
('+', '+', '+', '+', '+', '+', '+', '+', 'a', 'a', 'a', 'd', 'e', 'e', 'e')
Question How to find a specific index value in all possible combinations e.g What will be the index value of possible combination [+,-,+,+,+,+,-,-,a,a,b,c,c,e,c] ?
Here is the code for making all possible combinations
def ModelsProduct(modelsOne, modelsTwo, modelsThree, modelsFour,modelsFive):
modelsStepOne = list(product("+-",repeat = 8)) ## It gives total 12288 model combinations
modelsStepThree = [('a','a'),('a','b'),('a','c'),('a','d'),('a','e'),('b','b'),('b','c'),('b','d'),('b','e'),('c','c'),('c','d'),('c','e')]
modelsStepFour = [('d','d'),('d','e')]
modelsStepFive = [('e','e')]
#produce modelsOne
modelsStepTwo = [('a',),('b',)]
for one in modelsStepOne:
for two in modelsStepTwo:
for three in modelsStepThree:
for four in modelsStepFour:
for five in modelsStepFive:
modelsOne.append(one+two+three+four+five)
#produce modelsTwo
modelsStepTwo = [('a',),('b',)]
for one in modelsStepOne:
for two in modelsStepTwo:
for three in modelsStepThree:
for four in modelsStepFour:
for five in modelsStepFive:
modelsTwo.append(one+two+three+four+five)
#produce modelsThree
modelsStepTwo = [('a',),('b',)]
for one in modelsStepOne:
for two in modelsStepTwo:
for three in modelsStepThree:
for four in modelsStepFour:
for five in modelsStepFive:
modelsThree.append(one+two+three+four+five)
#ModelsFour
modelsStepTwo = [('a',),('d',)]
for one in modelsStepOne:
for two in modelsStepTwo:
for three in modelsStepThree:
for four in modelsStepFour:
for five in modelsStepFive:
modelsFour.append(one+two+three+four+five)
#ModelsFive
modelsStepTwo = [('a',),('e',)]
for one in modelsStepOne:
for two in modelsStepTwo:
for three in modelsStepThree:
for four in modelsStepFour:
for five in modelsStepFive:
modelsFive.append(one+two+three+four+five)
return modelsOne, modelsTwo, modelsThree, modelsFour, modelsFive
modelsOne, modelsTwo,modelsThree, modelsFour,modelsFive = ModelsProduct(modelsOne, modelsTwo, modelsThree, modelsFour, modelsFive)
modelsOne.index()so if you domodelsOne.index(('+', '+', '+', '+', '+', '+', '+', '+', 'a', 'a', 'a', 'd', 'd', 'e', 'e'))you will get 0, is it your question?