|
@@ -1,5 +1,6 @@
|
|
const util = require("util");
|
|
const util = require("util");
|
|
const Vector3 = require("./Vector3");
|
|
const Vector3 = require("./Vector3");
|
|
|
|
+const Moon = require("./Moon");
|
|
|
|
|
|
const input = [
|
|
const input = [
|
|
"<x=14, y=15, z=-2>",
|
|
"<x=14, y=15, z=-2>",
|
|
@@ -30,7 +31,7 @@ function calculateGravity(moonA, moonB) {
|
|
|
|
|
|
/**
|
|
/**
|
|
* @param {string[]} inputs The day's input
|
|
* @param {string[]} inputs The day's input
|
|
- * @returns {Vector3[]} An array of Vector3's representing the positions of moons
|
|
|
|
|
|
+ * @returns {Moon[]} An array of Moon objects
|
|
*/
|
|
*/
|
|
function parseInput(inputs) {
|
|
function parseInput(inputs) {
|
|
const moons = [];
|
|
const moons = [];
|
|
@@ -39,10 +40,10 @@ function parseInput(inputs) {
|
|
for (const position of inputs) {
|
|
for (const position of inputs) {
|
|
// eslint-disable-next-line no-shadow-restricted-names
|
|
// eslint-disable-next-line no-shadow-restricted-names
|
|
const [undefined, x, y, z] = position.match(parseRegex);
|
|
const [undefined, x, y, z] = position.match(parseRegex);
|
|
- moons.push(new Vector3(parseInt(x, 10), parseInt(y, 10), parseInt(z, 10)));
|
|
|
|
|
|
+ moons.push(new Moon(new Vector3(parseInt(x, 10), parseInt(y, 10), parseInt(z, 10))));
|
|
}
|
|
}
|
|
|
|
|
|
return moons;
|
|
return moons;
|
|
}
|
|
}
|
|
|
|
|
|
-console.log(util.inspect(parseInput(input)));
|
|
|
|
|
|
+// console.log(util.inspect(parseInput(input)));
|