A + B = 8 B + D = 8 A + C = 13 C - D = 6
How to find the values ββof A, B, C and D?
I assumed that the values ββwould be integer and positive, and did the following:
a = range(0,14) b = c = d = a for i in a: for x in b: for y in c: for z in d: if (a[i] + b[x] == 8 and a[i] + c[y] == 13 and b[x] + d[z] == 8 and c[y]-d[z]==6): print(a[i],b[x],c[y],d[z])
But that does not work. Even then, I expand the range to a = range(-100,100) . After solving the equation manually (using Google), I know that float are involved, for example. A = 3.5 etc.
But then how to solve the problem with Python.
source share