# How can avoid spheres interesecting?

I have an animation of objects running along a spline and they vary their scale following a sine pattern. The thing is that the spheres sometimes overlap. I have made a loop which contains another loop in order to detect distance minus the estimated radius to scale down or up depending on the space between. However I have failed miserably.

I know this require to reassign loops but I think I haven´t done it in a proper way. Objects are always scaled down.

The easiest way to avoid intersection is by using Close packing Node. Which is available on Animation Nodes + Extra Nodes build.