im currently writing a program which requires me to have a logical formula and then try every combination of True and False on that logical formula. Currently I have some code which creates a logical formula in the form : ({1} or not {2} or not {5} )and (not {1} or {6} )and (not {2} or not {3} )and ({3} or not {4} )and (not {4} or {5} or not {6} )
where the numbers need to be swapped out for every combination of true and false. The combos of true and false i work out using this line combos= product([True,False],repeat = no_variables)
. I currently have this code to attempt to do this:
for i in combos:
for j in range (no_variables):
k=j+1 //as the variables in the string do not start at 0
print(formulastring.format(k = i[j]))
however it doesn't work and returns this error:
print(formulastring.format(k = i[j]))
IndexError: Replacement index 1 out of range for positional args tuple
Any help would be greatly appreciated !