def advance(dt, n, bodies, pairs):
	for i in range(n):
		for pair in pairs:
			p1,p2 = pair
			vec1, v1, m1 = p1
			vec2, v2, m2 = p2
			x1, y1, z1 = vec1
			x2, y2, z2 = vec2

			dx = x1 - x2
			dy = y1 - y2
			dz = z1 - z2
			mag = dt * ((dx * dx + dy * dy + dz * dz) ** (-1.5))
			b1m = m1 * mag
			b2m = m2 * mag
			v1[0] -= dx * b2m
			v1[1] -= dy * b2m
			v1[2] -= dz * b2m
			v2[0] += dx * b1m
			v2[1] += dy * b1m
			v2[2] += dz * b1m

		for w in bodies:
			r, v, m = w
			r[0] += dt * v[0]
			r[1] += dt * v[1]
			r[2] += dt * v[2]
dataset/ETHPy150Open PythonJS/PythonJS/regtests/bench/nbody.py/advance/original