mirror of
https://github.com/Baipyrus/AoC-23.git
synced 2024-11-14 09:43:49 +00:00
correct manhattan distance
This commit is contained in:
parent
de288ab19c
commit
9ed473e718
@ -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
|
||||
)
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user