I want to make some king of bruteforcer where we have treee inputs and each of them has many propositions:
e = ['B[key-mini] = B[key-mini] +1','A[j] = key', 'A[key] = B[key-mini]', 'B[key-mini] = A[key-mini]','B[key]=B[key]-1','B[j]=B[j]+1','B[key+mini] = key', 'B[i] = key']
f = ['num = maxi -mini +1', 'num = maxi', 'num = mini','num = num +1','num =B[j-mini]','num =B[-mini]','num =A[j-mini]','num =A[i]']
g = ['A[i] =num','A[i] =j','B[j] =num','A[i] =B[j]','A[i] =num+j','A[j] =i','B[i] =i','B[j] =A[i]','B[i] =A[i]']
the objective is to moddify A = [1,-7,4,3,5,1,4,0,4]
and get at the end A = [-7,0,1,1,3,4,4,4,5]
this is the code:
def main(l1,l2,l3):
for o in l1:
for p in l2:
for q in l3:
if 'A' in list(globals()): del globals()["A"]
if 'B' in list(globals()): del globals()["B"]
if 'num' in list(globals()): del globals()["num"]
globals()['A']=[1,-7,4,3,5,1,4,0,4]
#---------------------------------------------------
maxi = max(A)
mini = min(A)
B = [0] * (maxi-mini+1)
for j in range(mini,maxi,+1): B[j-mini] = 0
for i in range(len(A)):
key=A[i]
exec(o) # executing a command from the ¨e¨ list
i = 0
for j in range(mini,maxi):
num = 0
exec(p) # executing a command from the ¨f¨ list
while num > 0:
exec(q) # executing a command from the ¨g¨ list
i = i+1
num = num -1
print('rep1 =',o,'rep2 =',p,'rep3 =',q)
print(A)
main(e,f,g)
my problem is when I try to print A
at the end, it doesn't change the list even tho the code modifies it