Solve 2025-08

This commit is contained in:
2025-12-08 14:09:00 +01:00
parent 63a7a93aba
commit 5421fde574
6 changed files with 119 additions and 1 deletions
+11 -1
View File
@@ -1,4 +1,4 @@
import { sumBy } from './array.ts';
import { sumArray, sumBy } from './array.ts';
export const Sides = {
TOP: 0,
@@ -167,3 +167,13 @@ export function calculateVariance<C extends Coordinate | CoordinateSide>(
coords.length
);
}
// TODO: add docs and tests
export function euclideanDistanceSqrtless(a: number[], b: number[]): number {
return sumArray(a.map((d, i) => Math.pow(d - b[i], 2)));
}
export function euclideanDistance(a: number[], b: number[]): number {
return Math.sqrt(euclideanDistanceSqrtless(a, b));
}