mirror of
https://github.com/Baipyrus/AoC-23.git
synced 2024-12-27 04:21:45 +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], []);
|
.reduce((a, i) => [...a, ...i], []);
|
||||||
const distances = galaxies.map((c, i) =>
|
const distances = galaxies.map((c, i) =>
|
||||||
galaxies.reduce(
|
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
|
0
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user