Here is another simple one:
The Challenge
Given two points in an n-dimensional space, output the distance between them, also called the Euclidean distance.
- The coordinates will be rational numbers; the only limits are the restrictions of your language.
- Lowest dimension is 1, highest is whatever your language can handle
- You may assume that the two points are of the same dimension and that there will be no empty input.
- The distance has to be correct to at least 3 decimal places. If your language does not support floating point numbers, output the nearest whole number.
Rules
- As usual, function or full program allowed.
- Input may be taken from STDIN, command line- or function arguments.
- Input format is up to you, specify which one you used in your answer.
- Output may be provided by printing to stdout or return value.
- This is code-golf so lowest byte-count wins! In case of a tie, the earlier answer wins.
Test cases
Each point is represented by a list of length n.
[1], [3] -> 2
[1,1], [1,1] -> 0
[1,2], [3,4] -> 2.82842712475
[1,2,3,4], [5,6,7,8] -> 8
[1.5,2,-5], [-3.45,-13,145] -> 150.829382085
[13.37,2,6,-7], [1.2,3.4,-5.6,7.89] -> 22.5020221314
Happy Coding!