0

I have tried these:

list = []
for i in range(-100, 100, 1):
    for j in range(-100, 100, 1):
        for k in range(-100, 100, 1):
            if i+j+k == 1:
                list.append([i,j,k])
arr = np.array(list)/100

Sample output is

array([[-0.98,  0.99,  0.99],
   [-0.97,  0.98,  0.99],
   [-0.97,  0.99,  0.98],
   [-0.96,  0.97,  0.99],
   [-0.96,  0.98,  0.98]...]

Do you have a better solution to save some processing time? Thank you!!

David Zayn
  • 181
  • 1
  • 1
  • 7
  • 1
    Floating point math is imprecise. If you want to get exact results, I would iterate over everything multiplied by 100 i.e. `np.arange(-100, 100, 1)` so you are using integers, and then divide the results by 100 at the very end. – Nick Oct 29 '22 at 04:14

0 Answers0