From 9ed473e718e4c4c2915202f182d30812f713b94f Mon Sep 17 00:00:00 2001 From: Baipyrus Date: Fri, 15 Dec 2023 19:23:01 +0100 Subject: [PATCH] correct manhattan distance --- Day11/Part1.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Day11/Part1.js b/Day11/Part1.js index 194cab1..20076ae 100644 --- a/Day11/Part1.js +++ b/Day11/Part1.js @@ -27,7 +27,7 @@ const galaxies = universe .reduce((a, i) => [...a, ...i], []); const distances = galaxies.map((c, i) => galaxies.reduce( - (a, n, j) => a + (j > i ? Math.abs(c.x - n.x + c.y - n.y) : 0), + (a, n, j) => a + (j > i ? Math.abs(c.x - n.x) + Math.abs(c.y - n.y) : 0), 0 ) );