Distance between two points in n-dimensional space
MATL, 2 bytes
ZP
Try it online!
The ZP
function (corresponding to MATLAB's pdist2
) computes all pairwise distances between two sets of points, using Euclidean distance by default. Each set of points is a matrix, and each point is a row. In this case it produces a single result, which is the distance between the two points.
MATL, 4.0 3 bytes
Thanks for -1 by @AndrasDeak!
-Zn
Reads two vectors (via implicit input that is requested by -
) then substracts those and calculates the norm of their difference with Zn
.
Try it Online!
Pyth, 2 bytes
.a
.a
- L2 norm of vector difference of A[0] and A[1].
Literally a function that does this problem
Try it here.