Execute on all players within stored distance

Solution 1:

I found a solution on YouTube:

.

Here is essentially what he is doing:

  • Take first entity with as @e[tag=a], Take the second entity with at @e[sort=nearest,limit=1]
  • Read and store the Position of both entities with
execute store result score @s math_in run data get entity @s Pos[0] 100
  • Compute the lengths x2-x1, y2-y1, z2-z1, square and add them
  • To compute the square root, he states to use the Newton-Raphson, 4 iterations approach. I don't have the math skills to quickly understand that method, but the results the datapack give are correct. To get the full list of commands, download his datapack.