def report_energy(bodies, pairs):
	e = 0.0
	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 = z2 - z1
		e -= (m1 * m2) / ((dx * dx + dy * dy + dz * dz) ** 0.5)

	for w in bodies:
		r, v, m = w
		vx, vy, vz = v
		#e += m * (vx * vx + vy * vy + vz * vz) / 2.0  ## TODO fix this
		a = vx * vx + vy * vy + vz * vz
		a /= 2.0
		e += m * a
	return e
dataset/ETHPy150Open PythonJS/PythonJS/regtests/bench/nbody.py/report_energy/swapped operands of `-`