data=[0,1,2,-1,-3,-4,-6,-3]
newarray =[]
sum = 0
i = 0
while i < data.length
val1 = data[i]
j = i+1
while j < data.length
val2 = data[j]
sum = val2 + val1
newarray << val2 if sum == 0
newarray << val1 if sum == 0
j = j+1
end
i = i+1
end
p newarray
#comment. the above give me the right answer which is -1 and 1…but it
doesnt give me 3 and -3…i need 3 and -3 also…how i do that
#comment. so it stop after finding the first two numbers that add to
zero…how do i make it keep going till the end of array…it should
include 3 and -3.