import math def gen matrix while matrix yield matrix matrix while matr

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import math
def gen(x):
matrix = [1]*4
while matrix != [x]*4:
yield matrix
matrix[0] += 1
i = 0
while matrix[i] > x and i < 3:
matrix[i] = 1
matrix[i+1] += 1
i += 1
yield [x]*4
def test(x):
D = (x[0]+x[3])**2 - 4*(x[0]*x[3] - x[2]*x[1])
return math.sqrt(D) - int(math.sqrt(D)) == 0
if __name__ == "__main__":
for i in gen(100):
if test(i):
print i