|
@@ -49,15 +49,18 @@ const tests = [
|
|
|
".664.598..",
|
|
|
];
|
|
|
|
|
|
+const input = await LoadInput(3);
|
|
|
+
|
|
|
// Build the find
|
|
|
-const testMap = BuildSchematicsMap(tests);
|
|
|
+const schematics = BuildSchematicsMap(input);
|
|
|
// Find all possible parts
|
|
|
-let testParts = ParseSchematics(testMap);
|
|
|
+let engineParts = ParseSchematics(schematics);
|
|
|
// Validate those parts
|
|
|
-testParts = ValidateEngineParts(testParts, testMap);
|
|
|
+engineParts = ValidateEngineParts(engineParts, schematics);
|
|
|
|
|
|
-// Get out output
|
|
|
-const sumOfPartNumbers = testParts.reduce((accumulator, part) => accumulator += part.PartNumber, 0);
|
|
|
+// Get our output
|
|
|
+// 551521: too low
|
|
|
+const sumOfPartNumbers = engineParts.reduce((accumulator, part) => accumulator += part.PartNumber, 0);
|
|
|
console.log(`The sum of part numbers is: ${sumOfPartNumbers}`);
|
|
|
|
|
|
/**
|
|
@@ -135,12 +138,18 @@ function ValidateEngineParts(potentialParts: EnginePart[], schematicsMap: string
|
|
|
const validParts: EnginePart[] = [];
|
|
|
|
|
|
for (const part of potentialParts) {
|
|
|
+ let symbolFound = false;
|
|
|
for (const point of part.Coordinates) {
|
|
|
if (BordersASymbol(point, schematicsMap)) {
|
|
|
+ symbolFound = true;
|
|
|
validParts.push(part);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
+ if (!symbolFound) {
|
|
|
+ console.log("No symbol found for the following part:");
|
|
|
+ Inspect(part);
|
|
|
+ }
|
|
|
}
|
|
|
return validParts;
|
|
|
}
|